比如我们一条 sql
select * from tb where id=xxx order by create_time desc limt 0,20
id 和 create_time 都是有索引的
但是 where 限定里面使用的 id,就会走 id 这个索引了,但是我们业务上需要用 create_time 排序,因为要取前 20 条,这个 sql 怎么优化会快些呢?
另外不使用索引排序的话 mysql 是怎么排序的? 把结果集加载到内存中进行排序吗?
另外不使用索引排序的话一般会 using filesort 的,但是我 explain 一下的话结果发现没有这个,这是为什么呢