开发者

What is a good design for Ranking System

I have a USER table, that has userId and point fields. At runtime, I want to know what is a ranking of a particular user base on their point. What is the best way to accomplish this:

1: Query all users into a l开发者_开发知识库ist. Sort the list base on point and do a binary search to find the ranking of that user. Sound like a bad idea here.

2: Is it possible to accomplish these tasks by creating database queries?

I expect 2000-5000 users.


SET @rownum := 0;

SELECT rank, userId, point 
FROM (
       SELECT @rownum := @rownum + 1 AS rank, userId, point
       FROM user ORDER BY point DESC
     ) 
as result WHERE userId = xxxxxxxx
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜