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