QUERY PLAN
GroupAggregate (cost=851.97..853.14 rows=58 width=36)
Group Key: c.project_id
-> Sort (cost=851.97..852.12 rows=60 width=36)
Sort Key: c.project_id
-> Hash Right Join (cost=650.67..850.19 rows=60 width=36)
Hash Cond: (tbl_case_assignments.case_id = c.id)
-> HashAggregate (cost=202.91..302.17 rows=7941 width=36)
Group Key: tbl_case_assignments.case_id
-> Seq Scan on tbl_case_assignments (cost=0.00..162.94 rows=7994 width=12)
-> Hash (cost=447.01..447.01 rows=60 width=8)
-> Seq Scan on tbl_cases c (cost=0.00..447.01 rows=60 width=8)
Filter: (project_id = ANY ('{3256,3935,3599,3477,3483,3458,3433,3423,3402,3381,3250,3379,3315,3357,3320,3165,3300,3239,3276,3252}'::integer[]))