QUERY PLAN
Aggregate (cost=35.21..35.22 rows=1 width=32)
-> GroupAggregate (cost=35.11..35.18 rows=2 width=36)
Group Key: sc.id
-> Sort (cost=35.11..35.12 rows=2 width=69)
Sort Key: sc.id
-> Hash Right Join (cost=22.20..35.10 rows=2 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=22.19..22.19 rows=1 width=37)
-> Hash Join (cost=11.40..22.19 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=11.38..11.38 rows=2 width=4)
-> Seq Scan on tbl_projects p (cost=0.00..11.38 rows=2 width=4)
Filter: (created_by = ANY ('{5493,5493}'::integer[]))