4,563,160 th visitor since 2017.2.1 ( Today : 54 )
Programming
No. 727
Name. swindler
Subject. mysql 인덱스를 타지 않는 쿼리 조사
Main Cate. MySQL
Sub Cate.
Date. 2013-11-20 14:35
Hit. 3472 (211.36.27.3)
File.
show variables like '%indexes%'; 와 같이 조사를 해 보면
아래 variable 값이 파악된다.
log_queries_not_using_indexes

set global log_queries_not_using_indexes=ON;
이렇게 값을 변경 할 수 있다.
이 경우 index를 타지 않는 모든 쿼리가 로그에 남는다.

이 경우 explain query 를 이용하여 plan을 조사할 수 있다.

EXPLAIN query 로 검사


explain select * from Table_Name where A='a' and B='b' order by C,D,E ;
해당 쿼리문이 인덱스를 타는지 안타는지 알기 위해서는 쿼리문 앞에 explain을 붙여주면 인덱스를 타는지 안타는지 알 수 있습니다.
type의 결과값이 ALL일 경우 인덱스를 타지 않고 있습니다. range,index등일 때 인덱스를 타고 있습니다.(system,const,eq_ref,range,index,ALL,fulltext)
key의 값이 해당 쿼리문이 타고 있는 인덱스입니다.

[바로가기 링크] : http://coolx.net/cboard/develop/727



Name
Password
Comment
Copyright © 1999-2017, swindler. All rights reserved. 367,611 visitor ( 1999.1.8-2004.5.26 ), 2,405,771 ( -2017.01.31)

  2HLAB   2HLAB_Blog   RedToolBox   Omil   Omil_Blog