이것이 Mysql이다 인덱스 실습

bluesky·2023년 12월 23일

TodayILearned

목록 보기
14/16

인덱스 실습하기

use sqldb;

select * from usertbl u 

show index from usertbl;

show table status like 'usertbl'

create index idx_usertbl_addr
  on usertbl (addr);


analyze table usertbl ;
show table status like 'usertbl';

create unique index idx_usertbl_name
  on usertbl (name);
  
create index idx_usertbl_name_birthYear
  on usertbl (name, birthYear);
  
drop index idx_usertbl_name ON usertbl;

select * from usertbl u where u.name = '윤종신' and u.birthYear = '1969' 

explain select* from usertbl u where u.name = '윤종신' and u.birthYear = '1969' 

select * from usertbl u where u.mobile2 = '6666666';

select * from usertbl u where u.name = '윤종신'

select * from

etc..

실습의 가치.

  • 실제로 인덱스 적용 전과 후의 내부 로직을 확인해본것.

배운것.

  • 인덱스는 열 단위에 생성된다.
  • where 절에서 사용되는 열에 인덱스를 만들어야 한다.
  • 자주사용해야 가치가 있다.
  • 외래키를 지정한 열에 자동으로 외래키 인덱스 생성
  • join에 자주 사용되는 열에 인덱스를 생성해주자.
profile
SMART https://github.com/dongseoki?tab=repositories

0개의 댓글