QUERY PLAN
Aggregate (cost=139.20..139.21 rows=1 width=32)
-> GroupAggregate (cost=139.15..139.18 rows=1 width=36)
Group Key: sc.id
-> Sort (cost=139.15..139.15 rows=1 width=17)
Sort Key: sc.id
-> Hash Right Join (cost=86.91..139.14 rows=1 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=86.90..86.90 rows=1 width=11)
-> Hash Join (cost=14.02..86.90 rows=1 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=14.01..14.01 rows=1 width=4)
-> Bitmap Heap Scan on tbl_projects p (cost=10.00..14.01 rows=1 width=4)
Recheck Cond: ((client_id = 982) AND (created_by = 1001))
-> BitmapAnd (cost=10.00..10.00 rows=1 width=0)
-> Bitmap Index Scan on tbl_projects_client_id_idx (cost=0.00..4.36 rows=11 width=0)
Index Cond: (client_id = 982)
-> Bitmap Index Scan on tbl_projects_created_by_idx (cost=0.00..5.38 rows=147 width=0)
Index Cond: (created_by = 1001)