I want to display a leaderboard in our mobile app. Each user has a “steps” property. The leaderboard will show the top 10 users with most steps.
The question is, how can display the current user position (rank) in the leaderboard? So for example if the current logged in user made 2500 steps, he is in 7483 place. How can I query efficiently to get that answer?
And also, we need to filter the leaderboard showing only certain segment of users. For exmaple display the leaderboard for all the users in segment 16.
Just for reference in Redis you can use ZRANK. In Mongo we can use the aggregation pipeline with $unwind. In Postgres we can use RANK OVER.