QUERY PLAN
Aggregate (cost=284.76..284.77 rows=1 width=64)
-> Hash Join (cost=270.04..284.33 rows=57 width=8)
Hash Cond: (eip.product_id = p.id)
-> Seq Scan on tbl_erp_inventory_products eip (cost=0.00..12.97 rows=497 width=12)
-> Hash (cost=269.52..269.52 rows=42 width=4)
-> Group (cost=268.89..269.10 rows=42 width=4)
Group Key: p.id
-> Sort (cost=268.89..268.99 rows=42 width=4)
Sort Key: p.id
-> Hash Right Join (cost=257.75..267.76 rows=42 width=4)
Hash Cond: (esosps.erp_inventory_product_id = eip_1.id)
-> Seq Scan on tbl_erp_sales_outbound_spent_products esosps (cost=0.00..8.11 rows=411 width=8)
-> Hash (cost=257.23..257.23 rows=42 width=8)
-> Hash Right Join (cost=129.94..257.23 rows=42 width=8)
Hash Cond: (sc.from_project = epips.project_id)
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..118.25 rows=1725 width=4)
-> Hash (cost=129.42..129.42 rows=42 width=12)
-> Hash Join (cost=124.34..129.42 rows=42 width=12)
Hash Cond: (eip_1.product_id = p.id)
-> Hash Right Join (cost=25.62..30.59 rows=42 width=12)
Hash Cond: (epips.erp_purchase_inbound_id = epis.id)
-> Seq Scan on tbl_erp_purchase_inbound_projects epips (cost=0.00..3.89 rows=189 width=8)
-> Hash (cost=25.09..25.09 rows=42 width=12)
-> Hash Left Join (cost=10.77..25.09 rows=42 width=12)
Hash Cond: (eip_1.erp_purchase_inbound_id = epis.id)
-> Seq Scan on tbl_erp_inventory_products eip_1 (cost=0.00..14.21 rows=42 width=32)
Filter: (inventory > '0'::numeric)
-> Hash (cost=8.12..8.12 rows=212 width=4)
-> Seq Scan on tbl_erp_purchase_inbounds epis (cost=0.00..8.12 rows=212 width=4)
-> Hash (cost=72.21..72.21 rows=2121 width=20)
-> Seq Scan on tbl_products p (cost=0.00..72.21 rows=2121 width=20)