MYSQL optimize 'IN' AND 'ORDER BY'

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

id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE test_askcomment ALL PRIMARY NULL NULL NULL 3 Using where; Using 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/25080.html

上一篇: Mysql Query中的索引表现得无所谓

下一篇: MYSQL优化'IN'和'ORDER BY'