QUERY PLAN
GroupAggregate (cost=872.98..874.09 rows=55 width=36)
Group Key: c.project_id
-> Sort (cost=872.98..873.12 rows=56 width=36)
Sort Key: c.project_id
-> Hash Right Join (cost=656.86..871.36 rows=56 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=438.23..438.23 rows=56 width=8)
-> Seq Scan on tbl_cases c (cost=0.00..438.23 rows=56 width=8)
Filter: (project_id = ANY ('{4139,4059,3956,3849,3919,3882,3917,3883,3898,3745,3538,3301,3105,3049,2831,2851}'::integer[]))