문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
database:mysql:index [2019/01/23 11:18] kwon37xi |
database:mysql:index [2020/11/24 18:55] kwon37xi [Covering Index] |
||
---|---|---|---|
줄 6: | 줄 6: | ||
* [[https:// | * [[https:// | ||
* https:// | * https:// | ||
- | > MySQL parses but **ignores “inline REFERENCES specifications”** (as defined in the SQL standard) where the references are defined as part of the column specification. MySQL accepts REFERENCES clauses only when specified as part of a separate FOREIGN KEY specification. | + | > MySQL parses but **ignores “inline REFERENCES specifications”** (as defined in the SQL standard) where the references are defined as part of the column specification. MySQL accepts REFERENCES clauses only when specified as part of a separate FOREIGN KEY specification. |
- | + | ||
- | + | ||
- | + | ||
===== Index 생성 ===== | ===== Index 생성 ===== | ||
줄 72: | 줄 68: | ||
WHERE type=12345 AND level > 3 | WHERE type=12345 AND level > 3 | ||
ORDER BY id | ORDER BY id | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Covering Index ===== | ||
+ | * [[https:// | ||
+ | * Index 에 있는 값만으로 '' | ||
+ | * Query 실행계획에서 **Extra: | ||
+ | * 실제 데이터를 찾아 읽는 것보다 훨씬 빠르다. | ||
+ | * 또한, 테이블 전체 컬럼이 select 대상이더라도 먼저 커버링 인덱스로 PK값만가져오고, | ||
+ | <code sql> | ||
+ | select a.* | ||
+ | from ( | ||
+ | -- 서브쿼리에서 커버링 인덱스로만 데이터 조건과 select column을 지정하고, | ||
+ | select userno | ||
+ | from usertest | ||
+ | where chgdate like ' | ||
+ | limit 100000, 100 | ||
+ | ) b join usertest a on b.userno = a.userno | ||
+ | -- 조인을 통해 나머지 모든 컬럼(a.*) 조회 | ||
</ | </ | ||