QUERY PLAN
GroupAggregate (cost=786.01..786.45 rows=22 width=36)
Group Key: c.project_id
-> Sort (cost=786.01..786.07 rows=22 width=36)
Sort Key: c.project_id
-> Hash Right Join (cost=571.02..785.52 rows=22 width=36)
Hash Cond: (tbl_case_assignments.case_id = c.id)
-> HashAggregate (cost=217.93..324.64 rows=8537 width=36)
Group Key: tbl_case_assignments.case_id
-> Seq Scan on tbl_case_assignments (cost=0.00..174.95 rows=8595 width=12)
-> Hash (cost=352.82..352.82 rows=22 width=8)
-> Seq Scan on tbl_cases c (cost=0.00..352.82 rows=22 width=8)
Filter: (project_id = ANY ('{4097,4114,4124,4127,4120,4111,4052,3797}'::integer[]))