QUERY PLAN
Aggregate (cost=177.14..177.15 rows=1 width=8)
-> Group (cost=177.12..177.13 rows=1 width=293)
Group Key: pci.id
-> Sort (cost=177.12..177.13 rows=1 width=4)
Sort Key: pci.id
-> Hash Right Join (cost=104.33..177.11 rows=1 width=4)
Hash Cond: (pcpp.purchase_invoice_id = pci.id)
-> Seq Scan on tbl_purchase_invoice_products pcpp (cost=0.00..64.38 rows=2238 width=4)
-> Hash (cost=104.32..104.32 rows=1 width=4)
-> Hash Right Join (cost=66.49..104.32 rows=1 width=4)
Hash Cond: (pip.purchase_invoice_id = pci.id)
-> Seq Scan on tbl_purchase_invoice_projects pip (cost=0.00..32.45 rows=2045 width=8)
-> Hash (cost=66.47..66.47 rows=1 width=12)
-> Seq Scan on tbl_purchase_contract_invoices pci (cost=0.00..66.47 rows=1 width=12)
Filter: ((cover_invoice_id IS NULL) AND (NOT is_cancel) AND ((invoice_type <> '-1'::smallint) OR (invoice_type IS NULL)) AND (contract_id = 4251))