mysql order by 能与查询使用相同的索引。
假设索引a、b、c
order by能使用索引最左前缀
order by a
order by a, b
order by a, b, c
order by a desc, b desc, c desc
如果where使用索引的最左前缀定义为常量,则order by能使用索引
where a = const order by b, c
where a = const and b = const order by c
where a = const and b > const order by b, c
下面排序不能使用索引
order a asc, b desc, c desc 排序方式不一致
where d = const order by b, c 丢失a
where a = const order by c 丢失b
where a = const order by a, d d不是索引
where a in(...) order by b, c 范围查询