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

相关文章
相关标签/搜索