오라클 힌트 강좌 #16
Oracle11g Invisible Indexes
use_invisible_indexes 힌트
no_use_invisible_indexes 힌트
이종철, 탑크리에듀(www.topcredu.co.kr)
실습코드 및 동영상 다시보기는 아래 URL에서
http://ojc.asia
Invisible Indexes
• Oracle11g R1 부터 Optimizer에게 보이지 않는 invisible index의 생성을 가능하도록
했는데 인덱스는 Index Segment에 동일하게 생성되지만 단지 보이는 않는다.
• 실무에서 인덱스 변경을 통해 SQL성능을 평가하는 경우가 많이 있으므로 실제
인덱스를 반영하기 전에 그 인덱스가 사용되었을 때의 성능을 평가하기 위해 사용한다.
• Invisible Index의 생성 방법은 다음과 같다.
CREATE INDEX 인덱스이름 ON 테이블이름(컬럼명,,,) INVISIBLE;
ALTER INDEX index_name INVISIBLE;
ALTER INDEX index_name VISIBLE;
Invisible Indexes Example - 1
• SQL> create index idx_myemp1_ename on myemp1(ename) invisible;
• SQL> set autotrace on explain
• SQL> set timing on
-- 인덱스가 invisible 상태 이므로 옵티마이저가 만든 실행계획에 반영되지 않는다.
• SQL> select count(1) from myemp1
where ename like '가%';
Invisible Indexes Example - 2
-- use_invisible_indexes 힌트를 사용하면 옵티마이저가 인덱스를 사용한다.
• SQL> select /*+ use_invisible_indexes */ count(1)
from myemp1 where ename like '가%';
• COUNT(1)
• ----------
• 1666666
Invisible Indexes Example - 3
-- 아래와 같이 세션 레벨에서 invisible index의 사용을 허가해도 된다.
• SQL> alter session set optimizer_use_invisible_indexes = true;
• SQL> select count(1) from myemp1
where ename like '가%';
• COUNT(1)
• ----------
• 1666666
-- 아래는 invisible index의 사용을 막았다.
SQL> select /*+ no_use_invisible_indexes */
count(1) from myemp1 where ename like
'가%';
COUNT(1)
----------
1666666
경 과: 00:00:01.54
This practice makes Expert!
PL/SQL단기속성(1일완성)SQL힌트/튜닝(단기2일교육)SQL기초과정

(오라클 인덱스 스캐닝 관련 힌트)오라클11g_invisible 인덱스 및 use_invisible_indexes,no_use_invisible_indexes 힌트,오라클힌트교육/SQL튜닝강좌,추천SQL/오라클/자바/스프링/JPA/닷넷/빅데이터/안드로이드/아이폰교육학원

  • 1.
    오라클 힌트 강좌#16 Oracle11g Invisible Indexes use_invisible_indexes 힌트 no_use_invisible_indexes 힌트 이종철, 탑크리에듀(www.topcredu.co.kr)
  • 2.
    실습코드 및 동영상다시보기는 아래 URL에서 http://ojc.asia
  • 3.
    Invisible Indexes • Oracle11gR1 부터 Optimizer에게 보이지 않는 invisible index의 생성을 가능하도록 했는데 인덱스는 Index Segment에 동일하게 생성되지만 단지 보이는 않는다. • 실무에서 인덱스 변경을 통해 SQL성능을 평가하는 경우가 많이 있으므로 실제 인덱스를 반영하기 전에 그 인덱스가 사용되었을 때의 성능을 평가하기 위해 사용한다. • Invisible Index의 생성 방법은 다음과 같다. CREATE INDEX 인덱스이름 ON 테이블이름(컬럼명,,,) INVISIBLE; ALTER INDEX index_name INVISIBLE; ALTER INDEX index_name VISIBLE;
  • 4.
    Invisible Indexes Example- 1 • SQL> create index idx_myemp1_ename on myemp1(ename) invisible; • SQL> set autotrace on explain • SQL> set timing on -- 인덱스가 invisible 상태 이므로 옵티마이저가 만든 실행계획에 반영되지 않는다. • SQL> select count(1) from myemp1 where ename like '가%';
  • 5.
    Invisible Indexes Example- 2 -- use_invisible_indexes 힌트를 사용하면 옵티마이저가 인덱스를 사용한다. • SQL> select /*+ use_invisible_indexes */ count(1) from myemp1 where ename like '가%'; • COUNT(1) • ---------- • 1666666
  • 6.
    Invisible Indexes Example- 3 -- 아래와 같이 세션 레벨에서 invisible index의 사용을 허가해도 된다. • SQL> alter session set optimizer_use_invisible_indexes = true; • SQL> select count(1) from myemp1 where ename like '가%'; • COUNT(1) • ---------- • 1666666 -- 아래는 invisible index의 사용을 막았다. SQL> select /*+ no_use_invisible_indexes */ count(1) from myemp1 where ename like '가%'; COUNT(1) ---------- 1666666 경 과: 00:00:01.54
  • 7.
    This practice makesExpert! PL/SQL단기속성(1일완성)SQL힌트/튜닝(단기2일교육)SQL기초과정