QUERY PLAN
Sort (cost=48.89..48.92 rows=10 width=186)
Sort Key: g.sort
-> GroupAggregate (cost=48.48..48.73 rows=10 width=186)
Group Key: g.id
-> Sort (cost=48.48..48.50 rows=10 width=158)
Sort Key: g.id
-> Hash Join (cost=34.14..48.31 rows=10 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=34.01..34.01 rows=10 width=8)
-> Bitmap Heap Scan on tbl_sales_group_relationships sgr (cost=23.45..34.01 rows=10 width=8)
Recheck Cond: (sales_id = 5493)
-> Bitmap Index Scan on tbl_sales_group_relationships_pkey (cost=0.00..23.45 rows=10 width=0)
Index Cond: (sales_id = 5493)