QUERY PLAN
Aggregate (cost=271.57..271.58 rows=1 width=32)
-> GroupAggregate (cost=268.20..270.68 rows=71 width=36)
Group Key: sc.id
-> Sort (cost=268.20..268.37 rows=71 width=17)
Sort Key: sc.id
-> Hash Right Join (cost=217.84..266.01 rows=71 width=17)
Hash Cond: (sci.contract_id = sc.id)
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..40.25 rows=1925 width=10)
-> Hash (cost=217.09..217.09 rows=60 width=11)
-> Hash Join (cost=148.42..217.09 rows=60 width=11)
Hash Cond: (sc.project_id = p.id)
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..64.37 rows=1636 width=15)
Filter: including_tax
-> Hash (cost=147.02..147.02 rows=112 width=4)
-> Bitmap Heap Scan on tbl_projects p (cost=5.15..147.02 rows=112 width=4)
Recheck Cond: (created_by = 1001)
-> Bitmap Index Scan on tbl_projects_created_by_idx (cost=0.00..5.12 rows=112 width=0)
Index Cond: (created_by = 1001)