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