QUERY PLAN
GroupAggregate (cost=914.28..915.60 rows=65 width=36)
Group Key: c.project_id
-> Sort (cost=914.28..914.45 rows=67 width=36)
Sort Key: c.project_id
-> Hash Right Join (cost=698.38..912.25 rows=67 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=67 width=8)
-> Seq Scan on tbl_cases c (cost=0.00..479.99 rows=67 width=8)
Filter: (project_id = ANY ('{3019,3027,2939,2893,2907,2759,2684,2695,2530,2508,2507,2504,2459,2458,2422,2080,2079,1983,1963,1938}'::integer[]))