QUERY PLAN
Aggregate (cost=265.18..265.19 rows=1 width=32)
-> GroupAggregate (cost=261.90..264.31 rows=69 width=36)
Group Key: sc.id
-> Sort (cost=261.90..262.07 rows=69 width=17)
Sort Key: sc.id
-> Hash Right Join (cost=213.45..259.79 rows=69 width=17)
Hash Cond: (sci.contract_id = sc.id)
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..38.66 rows=1866 width=10)
-> Hash (cost=212.67..212.67 rows=62 width=11)
-> Hash Join (cost=144.57..212.67 rows=62 width=11)
Hash Cond: (sc.project_id = p.id)
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..63.71 rows=1670 width=15)
Filter: including_tax
-> Hash (cost=143.19..143.19 rows=110 width=4)
-> Bitmap Heap Scan on tbl_projects p (cost=5.13..143.19 rows=110 width=4)
Recheck Cond: (created_by = 1001)
-> Bitmap Index Scan on tbl_projects_created_by_idx (cost=0.00..5.11 rows=110 width=0)
Index Cond: (created_by = 1001)