QUERY PLAN
GroupAggregate (cost=882.29..883.34 rows=52 width=36)
Group Key: c.project_id
-> Sort (cost=882.29..882.42 rows=53 width=36)
Sort Key: c.project_id
-> Hash Right Join (cost=674.01..880.77 rows=53 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=463.09..463.09 rows=53 width=8)
-> Seq Scan on tbl_cases c (cost=0.00..463.09 rows=53 width=8)
Filter: (project_id = ANY ('{4048,4047,4014,3950,3927,3949,3751,3899,3890,3886,3872,3857,3855,3816,3813,3786,3767,3764,3760,3752}'::integer[]))