mysql 分頁數據錯亂

 

 

最近在使用mysql 分頁查詢數據的時候發現返回的數據與預期的不同,顯示數據重複錯亂。html

官方文檔 有這樣一句話mysql

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.sql

One factor that affects the execution plan is LIMIT, so an ORDER BY query with and without LIMIT may return rows in different orders. Consider this query, which is sorted by the category column but nondeterministic with respect to the id and rating columns:        數據庫

說明當order by 列中有重複值的時候,mysql server 會看本身心情隨機處理返回結果。ide

當使用mysql 進行分頁查詢出現數據不一致問題時候 能夠看看order by 後面列數據是否有重複值this

 

參考文獻:數據庫內核月報 - 2015 / 06code

相關文章
相關標籤/搜索