QUERY PLAN
GroupAggregate (cost=870.60..871.46 rows=43 width=36)
Group Key: c.project_id
-> Sort (cost=870.60..870.71 rows=44 width=36)
Sort Key: c.project_id
-> Hash Right Join (cost=655.52..869.40 rows=44 width=36)
Hash Cond: (tbl_case_assignments.case_id = c.id)
-> HashAggregate (cost=217.55..323.95 rows=8512 width=36)
Group Key: tbl_case_assignments.case_id
-> Seq Scan on tbl_case_assignments (cost=0.00..174.70 rows=8570 width=12)
-> Hash (cost=437.42..437.42 rows=44 width=8)
-> Seq Scan on tbl_cases c (cost=0.00..437.42 rows=44 width=8)
Filter: (project_id = ANY ('{3037,3110,3126,3136,3137,3190,3203,3287,3329,3463,3957,4042,4097,4114,4120,4177}'::integer[]))