I have a table:
create table user (
id int primary key,
name varchar(20)
)engine=innodb;
insert into user values(1,'lily');
insert into user values(2,'tom');
insert into user values(3,'bob');
insert into user values(4,'jimi');
insert into user values(5,'moth');
If I run
explain select * from user where id in (1,2,3)
or
explain select name from user where id in (1,2,3)
Mysql shows that the type is range, but when run:
explain select id from user where id in (1,2,3)
Mysql shows that the type is index. So why is there such a difference?