QUERY PLAN
Aggregate (cost=341.42..341.43 rows=1 width=32)
-> GroupAggregate (cost=337.14..340.29 rows=90 width=36)
Group Key: sc.id
-> Sort (cost=337.14..337.36 rows=90 width=17)
Sort Key: sc.id
-> Hash Right Join (cost=280.02..334.22 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=279.12..279.12 rows=72 width=11)
-> Hash Join (cost=156.33..279.12 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=154.68..154.68 rows=132 width=4)
-> Bitmap Heap Scan on tbl_projects p (cost=5.30..154.68 rows=132 width=4)
Recheck Cond: (created_by = 1001)
-> Bitmap Index Scan on tbl_projects_created_by_idx (cost=0.00..5.27 rows=132 width=0)
Index Cond: (created_by = 1001)