Database/MySQL

MySQL Covering index

4번독수리 2017. 9. 19. 10:38

http://gywn.net/2012/04/mysql-covering-index/



create table usertest (
 userno int(11) not null auto_increment,
 userid varchar(20) not null default '',
 nickname varchar(20) not null default '',
 .. 중략 ..
 chgdate varchar(15) not null default '',
 primary key (userno),
 key chgdate (chgdate)
) engine=innodb;

위 테이블에서

select *
from usertest
where chgdate like '2010%'
limit 100000, 100

vs

select a.*
from (
      select userno
      from usertest
      where chgdate like '2012%'
      limit 100000, 100
) b join usertest a on b.userno = a.userno