QUERY PLAN
Aggregate (cost=421.32..421.33 rows=1 width=32)
-> HashAggregate (cost=382.30..407.38 rows=1115 width=36)
Group Key: sc.id
-> Hash Join (cost=322.67..371.15 rows=1115 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=215.91..215.91 rows=1774 width=4)
-> Seq Scan on tbl_projects p (cost=0.00..215.91 rows=1774 width=4)
Filter: (created_by = ANY ('{1001,1004,1005,1013,5087,5295,5300,5311,5329,5332,5420,5448,5449}'::integer[]))