QUERY PLAN
Aggregate (cost=404.58..404.59 rows=1 width=32)
-> HashAggregate (cost=370.14..392.28 rows=984 width=36)
Group Key: sc.id
-> Hash Right Join (cost=291.87..360.30 rows=984 width=17)
Hash Cond: (sci.contract_id = sc.id)
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..52.18 rows=1718 width=10)
-> Hash (cost=280.96..280.96 rows=873 width=11)
-> Hash Join (cost=221.71..280.96 rows=873 width=11)
Hash Cond: (sc.project_id = p.id)
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..55.24 rows=1523 width=15)
Filter: including_tax
-> Hash (cost=201.62..201.62 rows=1607 width=4)
-> Seq Scan on tbl_projects p (cost=0.00..201.62 rows=1607 width=4)
Filter: (created_by = ANY ('{1001,1004,1005,1013,5087,5295,5300,5311,5329,5332,5420}'::integer[]))