QUERY PLAN
Sort (cost=57.77..57.80 rows=10 width=158)
Sort Key: g.sort
-> Group (cost=57.56..57.61 rows=10 width=158)
Group Key: g.id
-> Sort (cost=57.56..57.58 rows=10 width=154)
Sort Key: g.id
-> Nested Loop (cost=34.27..57.39 rows=10 width=154)
-> Index Scan using tbl_users_pkey on tbl_users (cost=0.14..8.16 rows=1 width=4)
Index Cond: (id = 5493)
Filter: (user_status = '1'::type_global_user_status)
-> Hash Join (cost=34.14..49.13 rows=10 width=158)
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=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)