我使用此表(MySQL / Engine:MyISAM):
CREATE TABLE `activities` (
`id_activity` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_doc` int(10) unsigned NOT NULL DEFAULT '0',
`node_id` tinytext NOT NULL,
`title` tinytext NOT NULL,
`name` tinytext NOT NULL,
`keywords` tinytext NOT NULL,
`page_type` tinytext NOT NULL,
`page_screen_id` tinytext NOT NULL,
`page_screen_question` tinytext NOT NULL,
PRIMARY KEY (`id_activity`),
KEY `name` (`name`(255)),
FULLTEXT KEY `node_id` (`node_id`,`title`,`name`,`keywords`,`page_type`,`page_screen_id`,`page_screen_question`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
(大约有100000行)
这是我的问题:
EXPLAIN SELECT 1
FROM `activities`
GROUP BY `node_id`, `title`, `name`, `keywords`, `page_type`, `page_screen_id`, `page_screen_question`;
我不明白为什么我的查询使用临时...而且我不知道如何避免这种情况...谢谢
答案 0 :(得分:1)
应该是评论,但它更具可读性:
请执行此查询
SELECT CONCAT(table_schema, '.', table_name) AS tablename,
CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows,
CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') data,
CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx,
CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size,
ROUND(index_length / data_length, 2) idxfrac
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = database()
AND TABLE_NAME = 'your_table_name'
并检查您的表或索引是否真正适合内存。如果没有......你有答案。