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
,则服务器可以自由地以任何顺序返回这些行,并且可能会根据整体执行计划以不同的方式返回。换句话说,这些行的排序顺序对于无序的列是不确定的。
ORDER BY
,则服务器可以自由地以任何顺序返回这些行,并且可能会根据整体执行计划以不同的方式返回。换句话说,这些行的排序顺序对于无序的列是不确定的。ORDER BY
或 GROUP BY
和 LIMIT
子句的查询,优化器会在默认情况下尝试选择有序索引,因为这样做会加快查询执行速度。在 MySQL 5.7.33 之前,无法覆盖此行为,即使在使用其他优化可能更快的情况下也是如此。从 MySQL 5.7.33 开始,可以通过将 optimizer_switch
系统变量的 prefer_ordering_index
标志设置为off
.