QUERY PLAN
Aggregate (cost=135.98..135.99 rows=1 width=32)
-> Hash Join (cost=83.64..133.55 rows=971 width=7)
Hash Cond: (tbl_sales_contract_invoices.id = sci.id)
-> Seq Scan on tbl_sales_contract_invoices (cost=0.00..44.52 rows=2052 width=11)
-> Hash (cost=71.50..71.50 rows=971 width=4)
-> HashAggregate (cost=52.08..61.79 rows=971 width=4)
Group Key: sci.id
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..49.65 rows=971 width=4)
Filter: ((from_date >= '2024-08-01'::date) OR (NOT is_draft))