QUERY PLAN
Aggregate (cost=47.70..47.71 rows=1 width=8)
-> Group (cost=47.68..47.69 rows=1 width=330)
Group Key: sci.id
-> Sort (cost=47.68..47.69 rows=1 width=4)
Sort Key: sci.id
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..47.67 rows=1 width=4)
Filter: ((cover_invoice_id IS NULL) AND (NOT is_cancel) AND ((invoice_type <> '-1'::smallint) OR (invoice_type IS NULL)) AND (contract_id = 4074))