MYSQL优化'IN'和'ORDER BY'

EXPLAIN 
    SELECT * FROM test_askcomment WHERE cid IN(1,2,3) ORDER BY dateline DESC;

id select_type表类型possible_keys key key_len ref行额外1 SIMPLE test_askcomment ALL PRIMARY NULL NULL NULL 3使用where; 使用filesort


ALTER TABLE `test_askcomment ` ADD INDEX `index1` (`cid`);

ALTER TABLE `test_askcomment ` ADD INDEX `index2` (`dateline `);

尝试为您使用where子句或选择coloumns的coloumns编制索引

链接地址: http://www.djcxy.com/p/25079.html

上一篇: MYSQL optimize 'IN' AND 'ORDER BY'

下一篇: mysql fulltext index is used for MATCH() AGAINST but not for =