java - 游戏排行实现?
巴扎黑
巴扎黑 2017-04-17 17:52:39
0
4
1133

实现一个排行榜显示当前我的排行名次,还有我前5名和我后5名;
数据量几十万,用mysql,按表里一个score字段排序,怎么sql才没有效率问题?

巴扎黑
巴扎黑

reply all(4)
小葫芦

The amount of data is hundreds of thousands, use mysql, sort by a score field in the table...check and spit out every time, the disk IO alone is enough for you, and there is no need to consider the efficiency of SQL query.
There is no need to consider performance issues with cold data. I guess this is hot data. Don't use mysql to check, use redis, it can be easily done with a SortedSet.

洪涛

In this case, the efficiency problem cannot be solved at the SQL level

伊谢尔伦

Export data and use programming language to implement quick sorting algorithm. You cannot expect SQL to efficiently implement various sorting algorithms and just use them.

伊谢尔伦

This topic is interesting, but are your questions complete enough? Because the amount of data is hundreds of thousands, if we only sort by scores, most people may have the same score. Even if the scores are as high as millions, the top 5 and the bottom 5 may all have the same score.

For example, the current games from Tencent are all ranked in the circle of friends. This is another problem. It is very technical.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template