QUERY PLAN
Sort (cost=52.26..52.31 rows=20 width=186)
Sort Key: g.sort
-> GroupAggregate (cost=51.33..51.83 rows=20 width=186)
Group Key: g.id
-> Sort (cost=51.33..51.38 rows=20 width=158)
Sort Key: g.id
-> Hash Join (cost=35.75..50.90 rows=20 width=158)
Hash Cond: (g.id = sgr.group_id)
-> Seq Scan on tbl_groups g (cost=0.00..13.30 rows=330 width=154)
-> Hash (cost=35.50..35.50 rows=20 width=8)
-> Seq Scan on tbl_sales_group_relationships sgr (cost=0.00..35.50 rows=20 width=8)
Filter: (sales_id = ANY ('{5493,5495}'::integer[]))