QUERY PLAN
Aggregate (cost=252.97..252.98 rows=1 width=128)
-> Hash Left Join (cost=234.49..251.33 rows=109 width=10)
Hash Cond: (eip.erp_store_id = count_saleable_store.id)
-> Hash Join (cost=233.44..249.39 rows=109 width=12)
Hash Cond: (eip.product_id = p.id)
-> Seq Scan on tbl_erp_inventory_products eip (cost=0.00..14.50 rows=550 width=16)
-> Hash (cost=232.53..232.53 rows=73 width=4)
-> Group (cost=231.43..231.80 rows=73 width=4)
Group Key: p.id
-> Sort (cost=231.43..231.62 rows=73 width=4)
Sort Key: p.id
-> Hash Right Join (cost=216.12..229.17 rows=73 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..10.34 rows=534 width=8)
-> Hash (cost=215.21..215.21 rows=73 width=8)
-> Hash Right Join (cost=133.18..215.21 rows=73 width=8)
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=132.27..132.27 rows=73 width=12)
-> Hash Left Join (cost=114.99..132.27 rows=73 width=12)
Hash Cond: (epis.id = epips.erp_purchase_inbound_id)
-> Hash Left Join (cost=108.65..124.91 rows=73 width=12)
Hash Cond: (eip_1.erp_purchase_inbound_id = epis.id)
-> Hash Join (cost=98.75..114.81 rows=73 width=12)
Hash Cond: (eip_1.product_id = p.id)
-> Seq Scan on tbl_erp_inventory_products eip_1 (cost=0.00..15.88 rows=73 width=32)
Filter: (inventory > '0'::numeric)
-> Hash (cost=72.22..72.22 rows=2122 width=20)
-> Seq Scan on tbl_products p (cost=0.00..72.22 rows=2122 width=20)
-> Hash (cost=7.18..7.18 rows=218 width=4)
-> Seq Scan on tbl_erp_purchase_inbounds epis (cost=0.00..7.18 rows=218 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)
-> Hash (cost=1.02..1.02 rows=2 width=6)
-> Seq Scan on tbl_erp_stores count_saleable_store (cost=0.00..1.02 rows=2 width=6)