QUERY PLAN
Aggregate (cost=120.41..120.42 rows=1 width=8)
-> Sort (cost=106.58..108.88 rows=922 width=346)
Sort Key: sci.from_date DESC NULLS LAST, sci.created_at DESC NULLS LAST
-> HashAggregate (cost=51.96..61.18 rows=922 width=346)
Group Key: sci.id
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..49.65 rows=922 width=16)
Filter: ((cover_invoice_id IS NULL) AND ((from_date >= '2024-08-01'::date) OR (NOT is_draft)))