TIL

9.3(3) 인덱스 머지

인덱스 머지(index_merge)

인덱스 머지 - 교집합(index_merge_intersection)

EXPLAIN SELECT *
FROM employees
WHERE fiirst_name='Georgii' AND emp_no BETWEEN 10000 AND 20000;
type key key_len Extra
index_merge ix_firstname,PRIMARY 62.4 Using intersection (ix_firstname,PRMARY); Using where

인덱스 머지 - 합집합(index_merge_unioin)

SELECT *
FROM employees
WHERE first_name='MATT' OR hire_date='1987-03-01';
type key key_len Extra
index_merge ix_firstname,ix_hiredate 58.3 Using intersection (ix_firstname,ix_hiredate);

SQL 문장에서 두 조건이 AND 연사자로 연결된 경우 하나라도 인덱스를 사용할 수 있으면 인덱스 레인지 스캔으로 처리된다. 하지만 OR 연산자인 경우엔 하나라도 인덱스를 사용하지 못하면 항상 풀 테이블 스캔으로밖에 처리하지 못한다.

인덱스 - 머지 정렬 후 합집합(index_merge_sort_union)