QUERY PLAN
Limit (cost=211.66..211.67 rows=1 width=156)
-> Group (cost=211.66..211.67 rows=1 width=156)
Group Key: pci.id
-> Sort (cost=211.66..211.66 rows=1 width=156)
Sort Key: pci.id
-> Hash Right Join (cost=113.04..211.65 rows=1 width=156)
Hash Cond: (pcpp.purchase_invoice_id = pci.id)
-> Seq Scan on tbl_purchase_invoice_products pcpp (cost=0.00..87.25 rows=3025 width=4)
-> Hash (cost=113.03..113.03 rows=1 width=156)
-> Hash Right Join (cost=73.64..113.03 rows=1 width=156)
Hash Cond: (pip.purchase_invoice_id = pci.id)
-> Seq Scan on tbl_purchase_invoice_projects pip (cost=0.00..33.69 rows=2169 width=8)
-> Hash (cost=73.62..73.62 rows=1 width=156)
-> Seq Scan on tbl_purchase_contract_invoices pci (cost=0.00..73.62 rows=1 width=156)
Filter: ((cover_invoice_id IS NULL) AND (NOT is_cancel) AND ((invoice_type <> '-1'::smallint) OR (invoice_type IS NULL)) AND (contract_id = 4502))