QUERY PLAN
GroupAggregate (cost=739.27..739.69 rows=21 width=36)
Group Key: c.project_id
-> Sort (cost=739.27..739.32 rows=21 width=36)
Sort Key: c.project_id
-> Hash Right Join (cost=537.09..738.81 rows=21 width=36)
Hash Cond: (tbl_case_assignments.case_id = c.id)
-> HashAggregate (cost=205.23..305.58 rows=8028 width=36)
Group Key: tbl_case_assignments.case_id
-> Seq Scan on tbl_case_assignments (cost=0.00..164.82 rows=8082 width=12)
-> Hash (cost=331.60..331.60 rows=21 width=8)
-> Seq Scan on tbl_cases c (cost=0.00..331.60 rows=21 width=8)
Filter: (project_id = ANY ('{3959,3796,3837,3854,3878,3880,3955,3954}'::integer[]))