使用的filesort我有很简单的表:在简单查询
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的主题,但无法理解正确的答案。 谢谢。
只有41行,你为什么在意? – eggyal
因为我现在只有41行,但是在生产中有很多行。生产服务器(MySQL)也使用filesort。 –