| |
실행계획을 볼수 있는 방법은 아래와 같이 세가지가 있다
1. autotrace
2. explain plan
3. tkprof
1. autotrace 사용방법
SQL> set autotrace on;
=> sql을 실행한 후에 항상 실행계획이 표시된다.
2. explain plan
1) utlxplan.sql 파일 실행
SQL> @?/rdbms/admin/utlxplan.sql
2) Role 부여
drop role plustrace;
create role plustrace;
grant select on v_$sesstat to plustrace;
grant select on v_$statname to plustrace;
grant select on v_$session to plustrace
grant plustrace to dba with admin option;
3) trace를 사요할 사용자에게 plustrace Role을 부여한다
SQL> grant plustrace to scott;
4) autotrace모드를 on상태로 전이한다.
SQL> set autotrace on;
5) 실행할 sql문의 실행 계획을 plan_table 에 저장한다.
SQL> explain plan set statement_id = 'test1'
for select * from emp;
6) plan_table을 조회하여 실행 계획을 조회하려면
SQL> select id, parent_id, operation, options, object_name
from plan_table
where statement_id ='TEST1'
이렇게 설정을 해놓으면 select * from emp SQL문 사용에 대한
excute plan을 살펴 볼수 있다.
3. tkprof의 사용방법
1) trace 파일은 admin/udump에 가보면 볼수 있다.(ORA01455.trc)
2) tkprof ORA01455.trc emp.txt 이런 형식으로 파일을 변환한다
|