QUERY PLAN
GroupAggregate (cost=775.21..775.59 rows=19 width=36)
Group Key: c.project_id
-> Sort (cost=775.21..775.26 rows=19 width=36)
Sort Key: c.project_id
-> Hash Right Join (cost=560.31..774.81 rows=19 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=342.14..342.14 rows=19 width=8)
-> Seq Scan on tbl_cases c (cost=0.00..342.14 rows=19 width=8)
Filter: (project_id = ANY ('{4097,4114,4124,4127,4120,4111,4052}'::integer[]))