I have an online game currently using MySQL. I have a Player table looking like this:
create table player (
id integer primary key,
name varchar(50),
score integer
);
I have an index on "score" column and display the rankings like this:
select id, name, score from player order by score desc limit 100
I'd like to migrate my system to Redis (or, if some other NoSQL is more applicable to this kind of problem, please tell). So I wonder what is the way to display this kind of rankings table efficiently?
AFAICT, this could be a Map/Reduce job? I know next to nothing about Map/Reduce although I read some docs I still don't quite understand as I haven't been able to find any real-life examples.
Can someone please give me a rought example how to do the above query in Redis?
In redis you can use Sorted sets ( http://redis.io/commands#sorted_set )
When you have scored items in sorted set you can get top N by invoke ZRANGE players 0 N