QUERY PLAN
Aggregate (cost=112.39..112.40 rows=1 width=8)
-> Hash Join (cost=67.12..110.69 rows=680 width=0)
Hash Cond: (tbl_sales_contract_invoices.id = sci.id)
-> Seq Scan on tbl_sales_contract_invoices (cost=0.00..38.66 rows=1866 width=4)
-> Hash (cost=58.62..58.62 rows=680 width=4)
-> HashAggregate (cost=45.03..51.83 rows=680 width=4)
Group Key: sci.id
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..43.33 rows=680 width=4)
Filter: ((from_date >= '2024-08-01'::date) OR (NOT is_draft))