SQL 실행 계획 확인 방법 (SQL Plus 의 Autotrace 기능)

 

SQL*PLUS Autotrace 기능 활성화

- PLUSTRACE 권한 생성

SQL>conn / as sysdba

SQL>@?/sqlplus/admin/plustrce.sql (오타아님)

 

- 해당 사용자에게 PLUSTRACE 권한 부여

SQL>grant PLUSTRACE to scott;

 

- 해당 사용자로 로그인 후 PLAN Table 생성

SQL>conn scott/tiger

SQL>@?/rdbms/admin/utlxplan.sql

 

Autotrace 모드 설정

 

SQL>set autotrace on

SQL>set autotrace off

SQL>set autotrace traceonly

SQL>set autotrace traceonly explatin

SQL>set autotrace traceonly statistics

 

SQL*plus Autotrace 실습

- 100000 개의 Record 가 들어있는 Table 에서 name 컬럼에 abc 가 들어있는 Row 를 질의하는 SQL 의 실행계획 만들기.

SQL> set autotrace on

SQL> select * from scott.tt920

2 where name LIKE '%abc%';

- 위의 실행 계획을 보면 Operation 컬럼에 Row 를 보면 위쪽과 아래쪽을 비교하여 오른쪽으로 밀린 것을 먼저 수행, 즉 id=1 부터 수행 후 id=0 을 수행한다는 뜻 입니다.

- index 가 있을경우 더 다양한 실행계획이 나올 수 있습니다.

+ Recent posts