mysql 分页数据错乱
最近在使用mysql 分页查询数据的时候发现返回的数据与预期的不一样,显示数据重复错乱。
在官方文档 有这样一句话
If multiple rows have identical values in the
ORDER BYcolumns, 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.One factor that affects the execution plan is
LIMIT, so anORDER BYquery with and withoutLIMITmay return rows in different orders. Consider this query, which is sorted by thecategorycolumn but nondeterministic with respect to theidandratingcolumns:
说明当order by 列中有重复值的时候,mysql server 会看自己心情随机处理返回结果。
当使用mysql 进行分页查询出现数据不一致问题时候 可以看看order by 后面列数据是否有重复值
参考文献:数据库内核月报 - 2015 / 06
 
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号