QUERY PLAN
Aggregate (cost=291.55..291.56 rows=1 width=32)
-> HashAggregate (cost=288.23..290.36 rows=95 width=36)
Group Key: sc.id
-> Hash Right Join (cost=234.11..287.28 rows=95 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=233.10..233.10 rows=81 width=11)
-> Hash Join (cost=160.22..233.10 rows=81 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=158.39..158.39 rows=147 width=4)
-> Bitmap Heap Scan on tbl_projects p (cost=5.42..158.39 rows=147 width=4)
Recheck Cond: (created_by = 1001)
-> Bitmap Index Scan on tbl_projects_created_by_idx (cost=0.00..5.38 rows=147 width=0)
Index Cond: (created_by = 1001)