mysql排序分页乱的_Mysql 排序分页混乱
現象一
id=25這條數據,出現在第一頁、第二頁。
數據特征: 排序字段,重復率極高,僅有2個值。
數據庫版本:
現象二
相同數據,在以下數據庫版本,均排序分頁正常。
8.0.11
5.6.46
第一頁:
SELECT * FROM city order by FIELD(state,'ENABLE','DISABLE') LIMIT 0,10;
第二頁:
SELECT * FROM city order by FIELD(state,'ENABLE','DISABLE') LIMIT 10,10;
解決方案
關于現象一,官網給出以下解釋:
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.
當有多個重復值的時候,mysql server返回的是任意順序。具體的順序依賴執(zhí)行計劃。
關于現象二,暫沒合理的解釋。
相同的數據庫版本,類似的重復數據,分頁排序就是正常的。
相同的數據,不同的數據庫版本,分頁排序也是正常的。
參考
總結
以上是生活随笔為你收集整理的mysql排序分页乱的_Mysql 排序分页混乱的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql5.6的安装步骤_MySQL5
- 下一篇: mysql交互式创建表_用mysql语句