in的效率太慢!
select * from table1 where id in(1,2,3,4,5,6,7,8,9)
怎么才能提高效率呢?不用in?不会,求指教。
[解决办法]
- SQL code
--id 列上有索引的情况下select * from table1 where id = 1union allselect * from table1 where id = 2union allselect * from table1 where id = 3union allselect * from table1 where id = 4union allselect * from table1 where id = 5union allselect * from table1 where id = 6union allselect * from table1 where id = 7union allselect * from table1 where id = 8union allselect * from table1 where id = 9
[解决办法]
[解决办法]
还是另外建立一个码表 然后JOIN比较快。
[解决办法]
得看数据发布的情况,
如table1总记录数10万,id in(1,2,3,4,5,6,7,8,9)的记录有9.9万.
此时即使id上有索引也是没用的,基本上无法优化.