QUERY PLAN
Aggregate (cost=168.29..168.30 rows=1 width=8)
-> Group (cost=168.27..168.28 rows=1 width=293)
Group Key: pci.id
-> Sort (cost=168.27..168.28 rows=1 width=4)
Sort Key: pci.id
-> Hash Right Join (cost=99.20..168.26 rows=1 width=4)
Hash Cond: (pcpp.purchase_invoice_id = pci.id)
-> Seq Scan on tbl_purchase_invoice_products pcpp (cost=0.00..61.13 rows=2113 width=4)
-> Hash (cost=99.19..99.19 rows=1 width=4)
-> Hash Right Join (cost=63.00..99.19 rows=1 width=4)
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=62.99..62.99 rows=1 width=12)
-> Seq Scan on tbl_purchase_contract_invoices pci (cost=0.00..62.99 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 = 4122))