QUERY PLAN
Aggregate (cost=500.76..500.77 rows=1 width=32)
-> HashAggregate (cost=456.14..484.82 rows=1275 width=36)
Group Key: sc.id
-> Hash Join (cost=386.84..443.39 rows=1275 width=17)
Hash Cond: (sc.project_id = p.id)
-> Hash Right Join (cost=139.80..190.74 rows=2132 width=21)
Hash Cond: (sci.contract_id = sc.id)
-> Seq Scan on tbl_sales_contract_invoices sci (cost=0.00..45.33 rows=2133 width=10)
-> Hash (cost=118.25..118.25 rows=1724 width=15)
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..118.25 rows=1724 width=15)
Filter: including_tax
-> Hash (cost=223.55..223.55 rows=1879 width=4)
-> Seq Scan on tbl_projects p (cost=0.00..223.55 rows=1879 width=4)
Filter: (created_by = ANY ('{1001,1004,1005,1013,5087,5295,5300,5311,5332,5449,5467,5476}'::integer[]))