QUERY PLAN
Sort (cost=52.68..52.73 rows=20 width=158)
Sort Key: g.sort
-> Group (cost=52.15..52.25 rows=20 width=158)
Group Key: g.id
-> Sort (cost=52.15..52.20 rows=20 width=154)
Sort Key: g.id
-> Hash Join (cost=35.75..51.72 rows=20 width=154)
Hash Cond: (g.id = sgr.group_id)
-> Seq Scan on tbl_groups g (cost=0.00..14.12 rows=329 width=154)
Filter: (id <> 999999)
-> Hash (cost=35.50..35.50 rows=20 width=4)
-> Seq Scan on tbl_sales_group_relationships sgr (cost=0.00..35.50 rows=20 width=4)
Filter: (sales_id = ANY ('{5495,5493}'::integer[]))