QUERY PLAN
GroupAggregate (cost=699.17..701.00 rows=90 width=36)
Group Key: c.project_id
-> Sort (cost=699.17..699.40 rows=94 width=36)
Sort Key: c.project_id
-> Hash Right Join (cost=489.32..696.09 rows=94 width=36)
Hash Cond: (tbl_case_assignments.case_id = c.id)
-> HashAggregate (cost=210.26..313.12 rows=8229 width=36)
Group Key: tbl_case_assignments.case_id
-> Seq Scan on tbl_case_assignments (cost=0.00..168.84 rows=8284 width=12)
-> Hash (cost=277.89..277.89 rows=94 width=8)
-> Seq Scan on tbl_cases c (cost=0.00..277.89 rows=94 width=8)
Filter: (project_id = ANY ('{1018,1111}'::integer[]))