我有非常简单的表:
CREATE TABLE `navigation` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`parent_id` int(11) unsigned DEFAULT NULL,
`title` varchar(255) NOT NULL COMMENT 'Название ссылки',
`priority` tinyint(3) NOT NULL COMMENT 'Параметр сортировки'
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
只有 41 行。我也有非常简单的查询:
mysql> EXPLAIN SELECT t.id, t.parent_id, t.title, t.priority FROM navigation t ORDER BY t.priority ASC;
+----+-------------+-------+------+---------------+------+---------+------+------+----------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+----------------+
| 1 | SIMPLE | t | ALL | NULL | NULL | NULL | NULL | 41 | Using filesort |
+----+-------------+-------+------+---------------+------+---------+------+------+----------------+
1 row in set (0.00 sec)
我怎样才能避免使用filesort
?还是不可能?我已经阅读了很多关于 SO 的主题,但无法理解正确的答案。谢谢你。