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