QUERY PLAN
Aggregate (cost=67.19..67.20 rows=1 width=32)
-> Seq Scan on tbl_purchase_contract_invoices (cost=0.00..67.19 rows=1 width=6)
Filter: (((red_invoice_id IS NOT NULL) OR (NOT is_cancel)) AND (contract_id = 4459))