QUERY PLAN
GroupAggregate (cost=914.49..915.88 rows=69 width=36)
Group Key: c.project_id
-> Sort (cost=914.49..914.66 rows=71 width=36)
Sort Key: c.project_id
-> Hash Right Join (cost=698.43..912.30 rows=71 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=479.99..479.99 rows=71 width=8)
-> Seq Scan on tbl_cases c (cost=0.00..479.99 rows=71 width=8)
Filter: (project_id = ANY ('{4128,4090,4080,4074,4045,4028,4008,3969,3906,3873,3841,3807,3797,3781,3776,3749,3740,3709,3708,3707}'::integer[]))