QUERY PLAN
Aggregate (cost=342.63..342.64 rows=1 width=32)
-> GroupAggregate (cost=338.35..341.50 rows=90 width=36)
Group Key: sc.id
-> Sort (cost=338.35..338.58 rows=90 width=17)
Sort Key: sc.id
-> Hash Right Join (cost=281.23..335.43 rows=90 width=17)
Hash Cond: (sci.contract_id = sc.id)
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..45.33 rows=2133 width=10)
-> Hash (cost=280.33..280.33 rows=72 width=11)
-> Hash Join (cost=157.54..280.33 rows=72 width=11)
Hash Cond: (sc.project_id = p.id)
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..118.25 rows=1724 width=15)
Filter: including_tax
-> Hash (cost=155.88..155.88 rows=133 width=4)
-> Bitmap Heap Scan on tbl_projects p (cost=5.31..155.88 rows=133 width=4)
Recheck Cond: (created_by = 1001)
-> Bitmap Index Scan on tbl_projects_created_by_idx (cost=0.00..5.28 rows=133 width=0)
Index Cond: (created_by = 1001)