Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $YECBGYFECGEAFWHA as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2

Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $BBWFDDBHHYHDXXAB as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2
mysql order by limit的坑怎么解决_创想鸟

mysql order by limit的坑怎么解决

分页查询的时候遇到的坑:

发现的问题: 对单个无索引的字段进行排序后limit .发现当被排序字段有相同值时并且在limit范围内,取的值并不是正常排序后的值,

也就是说,当排在第N行的数据可取key1、 key2 时 , 排序结果可能是key1,也可能是key2。

mysql order by limit的坑怎么解决

排序+ limit 结果 (排序键无索引) 
按cnt取key_word分别前三结果:

mysql order by limit的坑怎么解决

智谱清言 - 免费全能的AI助手 智谱清言 – 免费全能的AI助手

智谱清言 – 免费全能的AI助手

智谱清言 - 免费全能的AI助手 2 查看详情 智谱清言 - 免费全能的AI助手

原文:

If multiple rows have identical values in the ORDER BY columns, the server is free to return those rows in any order, and may do so differently depending on the overall execution plan. In other words, the sort order of those rows is nondeterministic with respect to the nonordered columns.
是说如果order by的列有相同的值时, mysql会随机选取这些行,具体根据执行计划有所不同。

解决: order by 的列中包含一个索引列
此处增加主键id为排序列

以上就是mysql order by limit的坑怎么解决的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/271208.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
告别漫长等待:如何使用Composer和GuzzlePromises优化PHP异步操作性能
上一篇 2025年11月4日 12:24:52
微信朋友圈三天可见怎么设置_微信朋友圈查看权限更改方法
下一篇 2025年11月4日 12:25:02

相关推荐

发表回复

登录后才能评论
关注微信