实现一个排行榜显示当前我的排行名次,还有我前5名和我后5名;
数据量几十万,用mysql,按表里一个score字段排序,怎么sql才没有效率问题?
高洛峰2017-04-17 17:54:39
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.
PHP中文网2017-04-17 17:54:39
In this case, the efficiency problem cannot be solved at the SQL level
伊谢尔伦2017-04-17 17:54:39
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.
伊谢尔伦2017-04-17 17:54:39
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.