QUERY PLAN
Aggregate (cost=310.53..310.54 rows=1 width=32)
-> HashAggregate (cost=301.12..307.17 rows=269 width=36)
Group Key: sc.id
-> Hash Right Join (cost=243.55..298.43 rows=269 width=17)
Hash Cond: (sci.contract_id = sc.id)
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..44.52 rows=2052 width=10)
-> Hash (cost=240.71..240.71 rows=227 width=11)
-> Hash Join (cost=167.84..240.71 rows=227 width=11)
Hash Cond: (sc.project_id = p.id)
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..68.32 rows=1731 width=15)
Filter: including_tax
-> Hash (cost=162.66..162.66 rows=414 width=4)
-> Bitmap Heap Scan on tbl_projects p (cost=11.49..162.66 rows=414 width=4)
Recheck Cond: (created_by = 5295)
-> Bitmap Index Scan on tbl_projects_created_by_idx (cost=0.00..11.38 rows=414 width=0)
Index Cond: (created_by = 5295)