QUERY PLAN
GroupAggregate (cost=914.79..916.29 rows=74 width=36)
Group Key: c.project_id
-> Sort (cost=914.79..914.98 rows=77 width=36)
Sort Key: c.project_id
-> Hash Right Join (cost=698.50..912.38 rows=77 width=36)
Hash Cond: (tbl_case_assignments.case_id = c.id)
-> HashAggregate (cost=217.55..323.95 rows=8512 width=36)
Group Key: tbl_case_assignments.case_id
-> Seq Scan on tbl_case_assignments (cost=0.00..174.70 rows=8570 width=12)
-> Hash (cost=479.99..479.99 rows=77 width=8)
-> Seq Scan on tbl_cases c (cost=0.00..479.99 rows=77 width=8)
Filter: (project_id = ANY ('{4087,4086,3923,4077,4084,4070,4067,4007,4065,4076,4066,4072,4058,4026,4017,3955,4068,4075,4074,4073}'::integer[]))