QUERY PLAN
Aggregate (cost=520.08..520.09 rows=1 width=32)
-> GroupAggregate (cost=516.27..519.07 rows=80 width=36)
Group Key: sc.id
-> Sort (cost=516.27..516.47 rows=80 width=17)
Sort Key: sc.id
-> Hash Right Join (cost=467.74..513.75 rows=80 width=17)
Hash Cond: (sci.contract_id = sc.id)
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..38.34 rows=1834 width=10)
-> Hash (cost=466.88..466.88 rows=69 width=11)
-> Hash Join (cost=235.87..466.88 rows=69 width=11)
Hash Cond: (sc.project_id = p.id)
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..226.84 rows=1583 width=15)
Filter: including_tax
-> Hash (cost=234.28..234.28 rows=127 width=4)
-> Bitmap Heap Scan on tbl_projects p (cost=9.26..234.28 rows=127 width=4)
Recheck Cond: (created_by = 5087)
-> Bitmap Index Scan on tbl_projects_created_by_idx (cost=0.00..9.23 rows=127 width=0)
Index Cond: (created_by = 5087)