0
指数我有一些推荐表mysql命令仍用文件排序
CREATE TABLE IF NOT EXISTS `testimonials` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`description` text COLLATE utf8_unicode_ci NOT NULL,
`user` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`status` enum('active','test','inactive','') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'active',
`t_order` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `t_order` (`t_order`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=26 ;
和一些简单的任务:使人工分拣。
的SELECT
查询如下:
mysql> EXPLAIN SELECT t_order, id, title, description FROM testimonials WHERE status = 'active' ORDER BY t_order DESC;
输出:
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
| 1 | SIMPLE | testimonials | ALL | NULL | NULL | NULL | NULL | 23 | Using where; Using filesort |
ORDER BY
使用索引字段,但仍EXPLAIN
显示Using filesort
。
为什么无法从索引执行排序? 查询的东西?
感谢)
谢谢。对我来说,这个问题不够多行。多于1000行MySQL使用索引。 – alquist42