QUERY PLAN
Aggregate (cost=123.94..123.95 rows=1 width=8)
-> Sort (cost=109.66..112.04 rows=952 width=346)
Sort Key: sci.created_at DESC NULLS LAST
-> HashAggregate (cost=53.04..62.56 rows=952 width=346)
Group Key: sci.id
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..50.66 rows=952 width=12)
Filter: ((cover_invoice_id IS NULL) AND ((from_date >= '2024-08-01'::date) OR (NOT is_draft)))