tkprof orcl_ora_5155.trc ktprof_output.txt sort='(FCHELA,EXELA,PRSLEA)' print= 5
Usage: tkprof tracefile outputfile [explain= ] [table= ]
[print= ] [insert= ] [sys= ] [sort= ]
table=schema.tablename Use 'schema.tablename' with 'explain=' option.
explain=user/password Connect to ORACLE and issue EXPLAIN PLAN.
print=integer List only the first 'integer' SQL statements.
aggregate=yes|no
insert=filename List SQL statements and data inside INSERT statements.
sys=no TKPROF does not list SQL statements run as user SYS.
record=filename Record non-recursive statements found in the trace file.
waits=yes|no Record summary for any wait events found in the trace file.
sort=option Set of zero or more of the following sort options:
prscnt number of times parse was called
prscpu cpu time parsing
prsela elapsed time parsing
prsdsk number of disk reads during parse
prsqry number of buffers for consistent read during parse
prscu number of buffers for current read during parse
prsmis number of misses in library cache during parse
execnt number of execute was called
execpu cpu time spent executing
exeela elapsed time executing
exedsk number of disk reads during execute
exeqry number of buffers for consistent read during execute
execu number of buffers for current read during execute
exerow number of rows processed during execute
exemis number of library cache misses during execute
fchcnt number of times fetch was called
fchcpu cpu time spent fetching
fchela elapsed time fetching
fchdsk number of disk reads during fetch
fchqry number of buffers for consistent read during fetch
fchcu number of buffers for current read during fetch
fchrow number of rows fetched
userid userid of user that parsed the cursor
컬럼 | 의미 |
---|---|
tracefile | TKPROF 보고서 생성에 사용될 SQL 추적 파일 이름 |
outputfile | 생성할 TKPROF 보고서 이름 |
explain=user/password | EXPLAIN PLAN 명령으로 실행 계획 생성 * USER - EXPLAIN PLAN 명령을 수행할 오라클 유저 * PASSWD - 오라클 유저 패스워드 |
table=schema.tablename | 실행 계획 생성 시 사용할 테이블 * SCHEMA - 실행 계획 테이블 소유자 * TABLE - 실행 계획 테이블 |
sort=option | TKPROF 보고서 정렬 순서 |
print=integer | TKPROF 보고서에 기록된 SQL 수 지정 |
sys=no | SYS 유 저로 수행된 SQL 포함 여부, 기본 값 YES |
waits=yes/no | 대기 이벤트 포함 여부. 기본 값 YES |
aggregate=yes/no | 동일한 SQL을 통합해서 보여줄지 여부 지정. 기본 값 YES |
insert=filename | TKPROF 보고서 생성 데이터를 저장할 수 있는 스크립트 파일 생성 |
record=filename | SQL 추적 파일에 기록된 SYS 유저가 수행한 SQL 을 제외한 SQL을 지정된 파일에 기록 |
witdth=NUMBER | TKPROF 한 줄의 넓이 지정. SQL 실행 계획 정보를 기록할 때 적용됨 |
정렬 종류 | 의미 |
---|---|
prscnt | number of times parse was called |
prscpu | cpu time parsing |
prsela | elapsed time parsing |
prsdsk | number of disk reads during parse |
prsqry | number of buffers for consistent read during parse |
prscu | number of buffers for current read during parse |
prsmis | number of misses in library cache during parse |
execnt | number of execute was called |
execpu | cpu time spent executing |
exeela | elapsed time executing |
exedsk | number of disk reads during execute |
exeqry | number of buffers for consistent read during execute |
execu | number of buffers for current read during execute |
exerow | number of rows processed during execute |
exemis | number of library cache misses during execute |
fchcnt | number of times fetch was called |
fchcpu | cpu time spent fetching |
fchela | elapsed time fetching |
fchdsk | number of disk reads during fetch |
fchqry | number of buffers for consistent read during fetch |
fchcu | number of buffers for current read during fetch |
fchrow | number of rows fetched |
userid | userid of user that parsed the cursor |
SQL> ALTER SESSION SET TRACEFILE_IDENTIFIER='10046_TRACE' ;
Session altered.
SQL> ALTER SESSION SET TIMED_STATISTICS = TRUE ;
Session altered.
SQL> ALTER SESSION SET MAX_DUMP_FILE_SIZE=UNLIMITED ;
Session altered.
SQL> ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT FOREVER, LEVEL 12';
Session altered.
SQL> SELECT * FROM SCOTT.EMP WHERE ENAME ='TG';
no rows selected
SQL> SELECT * FROM SCOTT.EMP WHERE ENAME ='TG';
no rows selected
SQL> ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT OFF';
Session altered.
SQL>
=====================
PARSING IN CURSOR #4 len=41 dep=0 uid=59 oct=3 lid=59 tim=1391261760726 hv=2585646416 ad='af880ce8'
SELECT * FROM SCOTT.EMP WHERE ENAME ='TG'
END OF STMT
PARSE #4:c=20000,e=37333,p=4,cr=27,cu=0,mis=1,r=0,dep=0,og=1,tim=1391261760723
BINDS #4:
EXEC #4:c=0,e=25,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=1391261760805
WAIT #4: nam='SQL*Net message to client' ela= 2 driver id=1650815232 #bytes=1 p3=0 obj#=-1 tim=1391261760836
WAIT #4: nam='db file sequential read' ela= 11566 file#=12 block#=248371 blocks=1 obj#=611995 tim=1391261772478
WAIT #4: nam='db file scattered read' ela= 10763 file#=12 block#=248372 blocks=5 obj#=611995 tim=1391261783359
FETCH #4:c=0,e=22543,p=6,cr=7,cu=0,mis=0,r=0,dep=0,og=1,tim=1391261783411
*** 2013-01-08 21:20:26.470
WAIT #4: nam='SQL*Net message from client' ela= 12641592 driver id=1650815232 #bytes=1 p3=0 obj#=611995 tim=1391274425048
STAT #4 id=1 cnt=0 pid=0 pos=1 obj=611995 op='TABLE ACCESS FULL EMP (cr=7 pr=6 pw=0 time=22540 us)'
=====================
PARSING IN CURSOR #3 len=41 dep=0 uid=59 oct=3 lid=59 tim=1391274425459 hv=2585646416 ad='af880ce8'
SELECT * FROM SCOTT.EMP WHERE ENAME ='TG'
END OF STMT
PARSE #3:c=0,e=123,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=1391274425453
BINDS #3:
EXEC #3:c=0,e=65,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=1391274425587
WAIT #3: nam='SQL*Net message to client' ela= 3 driver id=1650815232 #bytes=1 p3=0 obj#=611995 tim=1391274425625
FETCH #3:c=0,e=97,p=0,cr=7,cu=0,mis=0,r=0,dep=0,og=1,tim=1391274425759
WAIT #3: nam='SQL*Net message from client' ela= 9141005 driver id=1650815232 #bytes=1 p3=0 obj#=611995 tim=1391283566811
STAT #3 id=1 cnt=0 pid=0 pos=1 obj=611995 op='TABLE ACCESS FULL EMP (cr=7 pr=0 pw=0 time=94 us)'
=====================
: 특정 구간 및 시점의 SQL 문제 파악 혹은 SQL 추적 파일 직접 분석
--------------------------------------------------------------------------------
SELECT *
FROM
SCOTT.EMP WHERE ENAME ='TG'
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.02 0.03 4 27 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.02 6 7 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3 0.02 0.05 10 34 0 0
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 59
Rows Row Source Operation
------- ---------------------------------------------------
0 TABLE ACCESS FULL EMP (cr=7 pr=6 pw=0 time=22540 us)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 1 0.00 0.00
db file sequential read 1 0.01 0.01
db file scattered read 1 0.01 0.01
SQL*Net message from client 1 12.64 12.64
********************************************************************************
SELECT *
FROM
SCOTT.EMP WHERE ENAME ='TG'
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 7 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3 0.00 0.00 0 7 0 0
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 59
Rows Row Source Operation
------- ---------------------------------------------------
0 TABLE ACCESS FULL EMP (cr=7 pr=0 pw=0 time=94 us)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 1 0.00 0.00
SQL*Net message from client 1 9.14 9.14
********************************************************************************
: 각 SQL의 평균 값으로 문제 SQL을 판단한다면 문제 SQL 선정에 시간 단축
********************************************************************************
SELECT *
FROM
SCOTT.EMP WHERE ENAME ='TG'
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.02 0.03 4 27 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.02 6 14 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 6 0.02 0.06 10 41 0 0
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 59
Rows Row Source Operation
------- ---------------------------------------------------
0 TABLE ACCESS FULL EMP (cr=7 pr=6 pw=0 time=22540 us)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 2 0.00 0.00
db file sequential read 1 0.01 0.01
db file scattered read 1 0.01 0.01
SQL*Net message from client 2 12.64 21.78
********************************************************************************