QUERY PLAN
Aggregate (cost=211.49..211.50 rows=1 width=8)
-> Group (cost=211.47..211.48 rows=1 width=301)
Group Key: pci.id
-> Sort (cost=211.47..211.48 rows=1 width=4)
Sort Key: pci.id
-> Hash Right Join (cost=112.96..211.46 rows=1 width=4)
Hash Cond: (pcpp.purchase_invoice_id = pci.id)
-> Seq Scan on tbl_purchase_invoice_products pcpp (cost=0.00..87.18 rows=3018 width=4)
-> Hash (cost=112.94..112.94 rows=1 width=4)
-> Hash Right Join (cost=73.56..112.94 rows=1 width=4)
Hash Cond: (pip.purchase_invoice_id = pci.id)
-> Seq Scan on tbl_purchase_invoice_projects pip (cost=0.00..33.68 rows=2168 width=8)
-> Hash (cost=73.55..73.55 rows=1 width=12)
-> Seq Scan on tbl_purchase_contract_invoices pci (cost=0.00..73.55 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 = 4472))