QUERY PLAN
Aggregate (cost=158.89..158.90 rows=1 width=8)
-> Group (cost=158.87..158.88 rows=1 width=293)
Group Key: pci.id
-> Sort (cost=158.87..158.88 rows=1 width=4)
Sort Key: pci.id
-> Hash Right Join (cost=96.94..158.86 rows=1 width=4)
Hash Cond: (pcpp.purchase_invoice_id = pci.id)
-> Seq Scan on tbl_purchase_invoice_products pcpp (cost=0.00..54.85 rows=1885 width=4)
-> Hash (cost=96.92..96.92 rows=1 width=4)
-> Hash Right Join (cost=61.27..96.92 rows=1 width=4)
Hash Cond: (pip.purchase_invoice_id = pci.id)
-> Seq Scan on tbl_purchase_invoice_projects pip (cost=0.00..30.52 rows=1952 width=8)
-> Hash (cost=61.25..61.25 rows=1 width=12)
-> Seq Scan on tbl_purchase_contract_invoices pci (cost=0.00..61.25 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 = 4042))