QUERY PLAN
GroupAggregate (cost=896.76..899.42 rows=130 width=36)
Group Key: c.project_id
-> Sort (cost=896.76..897.11 rows=138 width=36)
Sort Key: c.project_id
-> Hash Right Join (cost=677.98..891.86 rows=138 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=458.70..458.70 rows=138 width=8)
-> Seq Scan on tbl_cases c (cost=0.00..458.70 rows=138 width=8)
Filter: (project_id = ANY ('{1929,1925,1791,1018,1111,1460,1240,986,983,887,884,883,778,764,861,88,4179,4175}'::integer[]))