QUERY PLAN
Aggregate (cost=304.91..304.92 rows=1 width=32)
-> Hash Join (cost=221.72..302.39 rows=1008 width=6)
Hash Cond: (tbl_inventory_products.id = "ANY_subquery".id)
-> Seq Scan on tbl_inventory_products (cost=0.00..64.16 rows=2016 width=10)
-> Hash (cost=219.22..219.22 rows=200 width=4)
-> HashAggregate (cost=217.22..219.22 rows=200 width=4)
Group Key: "ANY_subquery".id
-> Subquery Scan on "ANY_subquery" (cost=204.26..215.78 rows=576 width=4)
-> HashAggregate (cost=204.26..210.02 rows=576 width=8)
Group Key: ip.id, pci.id
-> Hash Right Join (cost=157.90..201.38 rows=576 width=8)
Hash Cond: (pip.purchase_invoice_id = pci.id)
-> Seq Scan on tbl_purchase_invoice_projects pip (cost=0.00..30.94 rows=1994 width=8)
-> Hash (cost=150.70..150.70 rows=576 width=8)
-> Hash Left Join (cost=79.98..150.70 rows=576 width=8)
Hash Cond: (ip.purchase_invoice_id = pci.id)
-> Seq Scan on tbl_inventory_products ip (cost=0.00..69.20 rows=576 width=8)
Filter: (inventory > '0'::numeric)
-> Hash (cost=51.66..51.66 rows=2266 width=8)
-> Seq Scan on tbl_purchase_contract_invoices pci (cost=0.00..51.66 rows=2266 width=8)