在mysql中,有表结构如下:CREATETABLE`s_cate`(`id`int(10)unsignedNOTNULLauto_increment,`name`char(100)NOTNULLdefault'',`alias`char(20)NOTNULLdefault'',PRIMARYKEY(`id`))ENGINE=InnoDBAUTO_INCREMENT=9DEFAULTCHARSET=utf8比如有下面的数据在其中:+----+------+-------+|id|name|alias|+----+------+-------+|1|xxxx|||2|xxxx|||3|xxxx|||4|xxxx|||5|xxxx|||6|xxxx|||7|xxxx|||8|xxxx||+----+------+-------+使用下面的语句查询时,结果如下:explainselect*froms_catewhereidin(3,2,1,6,5,4)orderbyinstr('3,2,1,6,5,4',id);+----+-------------+--------+------+---------------+------+---------+------+------+-----------------------------+|id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|+----+-------------+--------+------+---------------+------+---------+------+------+-----------------------------+|1|SIMPLE|s_cate|ALL|PRIMARY|NULL|NULL|NULL|8|Usingwhere;Usingfilesort|+----+-------------+--------+------+---------------+------+---------+------+------+-----------------------------+请问如何优化,能让这里不用到filesort呢?补充一下请教公司dba的回答:函数返回的结果是动态的,静态索引不起作用
眼眸繁星
相关分类