You are on page 1of 2

TKPROF And Oracle Trace

The TKPROF program converts Oracle trace files into a more readable form. If you have a
problem query you can user TKPROF to get more information. To get the most out of the utility
you must enable timed statistics by setting the init.ora parameter or performing the following
command
ALTER SYSTEM SET TIMED_STATISTICS = TRUE;
If a suitable plan table is not present one can be created by doing the fooling as the !"! user
@ORACLE_HOME\rdbms\admin\utl!lan"s#l
CREATE $U%LIC SY&O&YM $LA&_TA%LE 'OR SYS"$LA&_TA%LE;
(RA&T SELECT) I&SERT) U$DATE) DELETE O& SYS"$LA&_TA%LE TO $U%LIC;
#ith this done we can trace a statement
ALTER SESSIO& SET S*L_TRACE = TRUE;
SELECT COU&T+,-
'ROM dual;
ALTER SESSIO& SET S*L_TRACE = 'ALSE;
The resulting trace file will be located in the USER_DUM$_DEST directory. This can then be
interpreted using TKPROF at the commmand prompt as follows
T.$RO' /tra0123il14 /5ut!ut23il14 1!lain=us1r6!ass75rd@s1r8i01
tabl1=s9s"!lan_tabl1
The resulting output file contains the following type of information for all !$% statements
processed& including the '%T(R !(!!IO) commands
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,
05unt = numb1r 53 tim1s OCI !r501dur1 7as 110ut1d
0!u = 0!u tim1 in s105nds 110utin:
1la!s1d = 1la!s1d tim1 in s105nds 110utin:
dis; = numb1r 53 !<9si0al r1ads 53 bu331rs 3r5m dis;
#u1r9 = numb1r 53 bu331rs :5tt1n 35r 05nsist1nt r1ad
0urr1nt = numb1r 53 bu331rs :5tt1n in 0urr1nt m5d1 +usuall9 35r u!dat1-
r57s = numb1r 53 r57s !r501ss1d b9 t<1 31t0< 5r 110ut1 0all
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,
SELECT COU&T+,-
'ROM dual
0all 05unt 0!u 1la!s1d dis; #u1r9 0urr1nt r57s
2222222 22222 22222 2222222 2222222 2222222 2222222 2222222
$ars1 = >">? >">? > > > >
E10ut1 = >">> >">> > > > >
'1t0< ? >">> >">> > = @ =
2222222 22222 22222 2222222 2222222 2222222 2222222 2222222
t5tal @ >">? >">? > = @ =
Miss1s in librar9 0a0<1 durin: !ars1A =
O!timiB1r :5alA CHOOSE
$arsin: us1r idA =?=
R57s R57 S5ur01 O!1rati5n
2222222 222222222222222222222222222222222222222222222222222
= SORT A((RE(ATE
= TA%LE ACCESS 'ULL DUAL
Things to loo* out for in the trace include
#hen tracing lots of statements at once& such as batch processes& you can quic*ly discard
those statements which have an acceptable cpu times. It+s often better to focus on those
statements that are ta*ing most of the cpu time.
Inefficient statements are mostly associated with a high number of bloc* visits. The query
column indicates bloc* visits for read consistency& including all query and subquery
processing. The current column indicates visits not related to read consistency& including
segment headers and bloc*s that are going to be updated.
The number of bloc*s read from dis* is shown in the dis* column. !ince dis* reads are
slower than memory reads you would e,pect this value to be significantly lower than the
sum of the query and current columns. If it is not you may have an issue with your buffer
cache.
%oc*ing problems and inefficient P%-!$% loops may lead to high cpu-elapsed values
even when bloc* visits are low.
.ultiple parse calls for a single statement imply a library cache issue.
Once you+ve identified your problem statements you can chec* the e,ecution plan to see
why the statement is performing badly.

You might also like