编辑: 我让查询变得更简单只是为了测试:
select *
from table1 where date >= '2012-02-02' order by date, col_2 desc
我在 date 和 col_2 上有复合索引,但是当我对查询进行解释时,它显示:
+----+-------------+------------------+-------+--------------------------+-----------------+---------+------+------+-----------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+------------------+-------+--------------------------+-----------------+---------+------+------+-----------------------------+
| 1 | SIMPLE | table1 | range | col_2_date, date | col_2_date | 4 | NULL | 4643 | Using where; Using filesort |
+----+-------------+------------------+-------+--------------------------+-----------------+---------+------+------+-----------------------------+
如果我在 col_2 和 date 列上有索引,为什么 mySQL 使用文件排序,我该如何防止它?