database.sarang.net
UserID
Passwd
Database
DBMS
ㆍMySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
MySQL Q&A 28152 게시물 읽기
No. 28152
explain range type에서의 = 사용여부
작성자
오아시셔
작성일
2009-04-09 12:07ⓒ
2009-04-09 12:08ⓜ
조회수
5,689

안녕하세요 explain을 통한 쿼리 최적화 분석중 의문점이 생겨서 글을 올립니다
다음은 mysql 메뉴얼에 있는 내용입니다

ref

All rows with matching index values are read from this table for each combination of rows from the previous tables. ref is used if the join uses only a leftmost prefix of the key or if the key is not a PRIMARY KEY or UNIQUE index (in other words, if the join cannot select a single row based on the key value). If the key that is used matches only a few rows, this is a good join type.

ref can be used for indexed columns that are compared using the = or <=> operator. In the following examples, MySQL can use a ref join to process ref_table:

range

Only rows that are in a given range are retrieved, using an index to select the rows. The key column in the output row indicates which index is used. The key_len contains the longest key part that was used. The ref column is NULL for this type.

range can be used when a key column is compared to a constant using any of the =, <>, >, >=, <, <=, IS NULL, <=>, BETWEEN, or IN() operators: 



여기서 range 타입의 경우 = 가 왜 포함이 되는 거지요?
= 로 비교되는 거면 위의 ref 타입과 같은게 아닌가요?

이 글에 대한 댓글이 총 3건 있습니다.

ahhhhhhhhhhhhhh~~  can't write hangul..

ref  is used when  key column is the leftmost  in possible index

range  is used when it' is not

when   unique key   (aaa,bbb)  is used

if the condition  is  aaa =  'const'    then   ref will be used

but  if condition is bbb = 'const'    range will be used

이경환(babocom)님이 2009-04-09 12:13에 작성한 댓글입니다.

한글이 안써지시는데도 답변 달아주셔서 감사합니다..^^;
괜찬으시다면 제가 이해한 것이 맞는지 확인부탁드립니다.

1. 단일 index이고 = 로 할 경우 무조건 ref 타입이 되는거고

2. 복합 index 일 경우 index의 첫번째 컬럼이 where 절에 =로 오는 경우 ref 타입

3. 복합 index 일 경우 index의 첫번째가 아닌 컬럼이 where 절에 =로 오는 경우 range 타입

이상입니다...길지 않고 간단한 문장의 영어댓글인데도 확인을 받는게 쫌 부끄럽네요...^^;

오아시셔(jjhoasis)님이 2009-04-09 14:16에 작성한 댓글입니다.

네 맞습니다.

이경환(babocom)님이 2009-04-10 02:51에 작성한 댓글입니다.
[Top]
No.
제목
작성자
작성일
조회
28155Group by, Order by [1]
jhkang
2009-04-09
5801
28154innodb 쿼리 테스트 하려 할 때 애로사항 관련 [1]
오아시셔
2009-04-09
5313
28153explain range와 ref 중 rows 가 같을경우 속도문제 [1]
전정훈
2009-04-09
5300
28152explain range type에서의 = 사용여부 [3]
오아시셔
2009-04-09
5689
28151mysql odbc 3.51 initial statement 옵션질문입니다. [1]
우짜라
2009-04-08
5768
28150Aborted_clients 수치가 너무 높게 나오고 있는데 어떻게 줄일 수 있을까요? [2]
김승동
2009-04-08
6146
28149join과 group by 문을 어떻게 사용할지 도와주세요 [2]
최동성
2009-04-08
5481
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.018초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다