QUERY PLAN
Aggregate (cost=424.72..424.73 rows=1 width=32)
-> HashAggregate (cost=385.73..410.79 rows=1114 width=36)
Group Key: sc.id
-> Hash Join (cost=326.11..374.59 rows=1114 width=17)
Hash Cond: (sc.project_id = p.id)
-> Hash Right Join (cost=84.59..128.15 rows=1865 width=21)
Hash Cond: (sci.contract_id = sc.id)
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..38.66 rows=1866 width=10)
-> Hash (cost=63.71..63.71 rows=1670 width=15)
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..63.71 rows=1670 width=15)
Filter: including_tax
-> Hash (cost=219.04..219.04 rows=1799 width=4)
-> Seq Scan on tbl_projects p (cost=0.00..219.04 rows=1799 width=4)
Filter: (created_by = ANY ('{1001,1004,1005,1013,5087,5295,5300,5311,5329,5332,5420,5448,5449}'::integer[]))