QUERY PLAN
Aggregate (cost=139.18..139.19 rows=1 width=32)
-> Hash Join (cost=85.73..136.67 rows=1002 width=8)
Hash Cond: (tbl_sales_contract_invoices.id = sci.id)
-> Seq Scan on tbl_sales_contract_invoices (cost=0.00..45.33 rows=2133 width=12)
-> Hash (cost=73.21..73.21 rows=1002 width=4)
-> HashAggregate (cost=53.17..63.19 rows=1002 width=4)
Group Key: sci.id
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..50.66 rows=1002 width=4)
Filter: ((from_date >= '2024-08-01'::date) OR (NOT is_draft))