QUERY PLAN
Aggregate (cost=303.47..303.48 rows=1 width=32)
-> GroupAggregate (cost=300.19..302.61 rows=69 width=36)
Group Key: sc.id
-> Sort (cost=300.19..300.36 rows=69 width=17)
Sort Key: sc.id
-> Hash Right Join (cost=252.04..298.08 rows=69 width=17)
Hash Cond: (sci.contract_id = sc.id)
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..38.45 rows=1845 width=10)
-> Hash (cost=251.30..251.30 rows=59 width=11)
-> Hash Join (cost=186.27..251.30 rows=59 width=11)
Hash Cond: (sc.project_id = p.id)
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..60.86 rows=1585 width=15)
Filter: including_tax
-> Hash (cost=184.89..184.89 rows=110 width=4)
-> Bitmap Heap Scan on tbl_projects p (cost=5.13..184.89 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)