QUERY PLAN
Aggregate (cost=502.48..502.49 rows=1 width=32)
-> HashAggregate (cost=457.85..486.54 rows=1275 width=36)
Group Key: sc.id
-> Hash Join (cost=388.55..445.10 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=225.10..225.10 rows=1892 width=4)
-> Seq Scan on tbl_projects p (cost=0.00..225.10 rows=1892 width=4)
Filter: (created_by = ANY ('{1001,1004,1005,1013,5087,5295,5300,5311,5332,5449,5467,5476}'::integer[]))