QUERY PLAN
Limit (cost=231.49..231.59 rows=40 width=156)
-> Sort (cost=231.49..231.65 rows=65 width=156)
Sort Key: p.updated_at DESC
-> Group (cost=229.21..229.53 rows=65 width=156)
Group Key: p.id
-> Sort (cost=229.21..229.37 rows=65 width=156)
Sort Key: p.id
-> Hash Right Join (cost=214.26..227.25 rows=65 width=156)
Hash Cond: (esosps.erp_inventory_product_id = eip.id)
-> Seq Scan on tbl_erp_sales_outbound_spent_products esosps (cost=0.00..10.34 rows=534 width=8)
-> Hash (cost=213.46..213.46 rows=64 width=160)
-> Hash Right Join (cost=131.52..213.46 rows=64 width=160)
Hash Cond: (sc.from_project = epips.project_id)
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..68.32 rows=1732 width=4)
-> Hash (cost=130.72..130.72 rows=64 width=164)
-> Hash Left Join (cost=114.88..130.72 rows=64 width=164)
Hash Cond: (epis.id = epips.erp_purchase_inbound_id)
-> Hash Left Join (cost=108.54..123.47 rows=64 width=164)
Hash Cond: (eip.erp_purchase_inbound_id = epis.id)
-> Hash Join (cost=98.75..113.51 rows=64 width=164)
Hash Cond: (eip.product_id = p.id)
-> Seq Scan on tbl_erp_inventory_products eip (cost=0.00..14.60 rows=64 width=32)
Filter: (inventory > '0'::numeric)
-> Hash (cost=72.22..72.22 rows=2122 width=156)
-> Seq Scan on tbl_products p (cost=0.00..72.22 rows=2122 width=156)
-> Hash (cost=7.13..7.13 rows=213 width=4)
-> Seq Scan on tbl_erp_purchase_inbounds epis (cost=0.00..7.13 rows=213 width=4)
-> Hash (cost=3.93..3.93 rows=193 width=8)
-> Seq Scan on tbl_erp_purchase_inbound_projects epips (cost=0.00..3.93 rows=193 width=8)