QUERY PLAN
Aggregate (cost=31.94..31.95 rows=1 width=32)
-> GroupAggregate (cost=31.88..31.92 rows=1 width=36)
Group Key: sc.id
-> Sort (cost=31.88..31.89 rows=1 width=69)
Sort Key: sc.id
-> Hash Right Join (cost=18.98..31.87 rows=1 width=69)
Hash Cond: (sci.contract_id = sc.id)
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..12.10 rows=210 width=36)
-> Hash (cost=18.96..18.96 rows=1 width=37)
-> Hash Join (cost=8.17..18.96 rows=1 width=37)
Hash Cond: (sc.project_id = p.id)
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..10.70 rows=35 width=41)
Filter: including_tax
-> Hash (cost=8.16..8.16 rows=1 width=4)
-> Index Scan using tbl_projects_created_by_idx on tbl_projects p (cost=0.14..8.16 rows=1 width=4)
Index Cond: (created_by = 5495)