In a case, I need SQL like this, in Mysql, innodb engine:
**select** code, title **from** my_table **where** code **in** ('cx001', 'kd309', 'yb020');
The column code
has a unique index. Would the SQL run with the index? Would it scan the whold table?
Comparing with doing " where code='cx001' " three times, would my SQL run faster?
with Chinese following: 我有如下的一个sql语句,使用Mysql的innodb引擎: select code, title from my_table where code in ('cx001', 'kd309', 'yb020'); code列上有唯一索引,那么这句SQL是否能使用此索引?会不会造成全表遍历? 与每个id都直接用" code = 'xxxxx' "比起来,哪个会更快一些呢?
EXPLAIN
statement. – Gumbo 53 mins ago=
. – dasblinkenlight 52 mins ago