QUERY PLAN
Aggregate (cost=495.59..495.60 rows=1 width=32)
-> GroupAggregate (cost=492.41..494.75 rows=67 width=36)
Group Key: sc.id
-> Sort (cost=492.41..492.58 rows=67 width=17)
Sort Key: sc.id
-> Hash Right Join (cost=444.49..490.38 rows=67 width=17)
Hash Cond: (sci.contract_id = sc.id)
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..38.34 rows=1834 width=10)
-> Hash (cost=443.77..443.77 rows=58 width=11)
-> Hash Join (cost=212.76..443.77 rows=58 width=11)
Hash Cond: (sc.project_id = p.id)
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..226.84 rows=1583 width=15)
Filter: including_tax
-> Hash (cost=211.42..211.42 rows=107 width=4)
-> Bitmap Heap Scan on tbl_projects p (cost=5.11..211.42 rows=107 width=4)
Recheck Cond: (created_by = 1001)
-> Bitmap Index Scan on tbl_projects_created_by_idx (cost=0.00..5.08 rows=107 width=0)
Index Cond: (created_by = 1001)