17 Şubat 2011

tkprof – trcsess trace komutları

Bu yazım boyunca trcsess ve tkprof komutlarının nasıl kullanılacağını anlatıyor olacağım. Öncelikle bir komut satırı açarak trace ettiğimiz session ve/veya servisler ile ilgili trace file ların bulunduğu dosya altına gidiyoruz. Bu dosya Oracle 11g R1 ve sonrası için aşağıdaki uzantılarda bulunabilir.

Linux --> $ORACLE_BASE/diag/rdbms/sid/sid/trace/
Windows --> $ORACLE_BASE\diag\rdbms\sid\sid\trace

trcsess komutunun parametreleri aşağıdaki gibidir:

trcsess [output=output_file_name] [session=session_id] [clientid=client_identifier] [service=service_name] [action=action_name] [module=module_name] []

Daha sonra trcsess komutuna input dosyarını vermelisiniz. Örneğin;

oracle> trcsess output=tracedosyam.trc $ORACLE_BASE/diag/rdbms/orcl/orcl/trace/*.trc

Input dosyalarını verirken belirli kısıtlamalar yapabiliriz. Örneğin;

oracle> trcsess output=tracedosyam.trc service=service_name module=module_name $ORACLE_BASE/diag/rdbms/orcl/orcl/trace/*.trc

Bu kısıtlamalar trcsess komutunun oluşturacağı output dosyasının büyüklüğünü ve sizin aradığınız verileri bulmanızda zorlanmamanızıda sağlayacaktır.

trcsess komutunun output dosyasına bir örnek:

*** [ Unix process pid: 1907 ]
*** 2011-02-02 05:19:19.19
*** 2011-02-02 05:19:19.19
*** 2011-02-02 05:19:19.19
*** 2011-02-02 05:19:19.19

====================
PARSING IN CURSOR #4 len=23 dep=0 uid=82 oct=3 lid=82 tim=1256987632548698 hv=4584569525 ad='34b8f852' sqlid='f34brkbt8brk5'
select * from mytable
END OF STMT
PARSE #4:c=45698,e=52459,p=35,cr=403,cu=0,mis=1,r=0,dep=0,og=1,tim=1254589632547895
EXEC #4:c=0,e=16,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=1478596541235896
FETCH #4:c=1000,e=581,p=6,cr=6,cu=0,mis=0,r=1,dep=0,og=1,tim=1124589632545896
FETCH #4:c=0,e=45,p=0,cr=1,cu=0,mis=0,r=15,dep=0,og=1,tim=1785421358965412

FETCH #4:c=0,e=49,p=0,cr=1,cu=0,mis=0,r=1,dep=0,og=1,tim=1456785412563987
STAT #4 id=1 cnt=107 pid=0 pos=1 obj=70285 op='TABLE ACCESS FULL MYTABLE (cr=15 pr=6 pw=6 time=0 us cost=3 size=7276 card=107)'
*** [ Unix process pid: 1908 ]
*** 2011-02-02 05:29:29.29
*** 2011-02-02 05:29:29.29
*** 2011-02-02 05:29:29.29
*** 2011-02-02 05:29:29.29


Bu dosyayı formatlamak için kullandığımız komut ise tkprof

tkprof inputfile outputfile [waits=yes|no] [sort=option] [print=n] [aggregate=yes|no] [insert=sqlscritfile] [sys=yes|no] [width=n] [table=schema.table] [explain=user/password] [record=statementfile]

Örneğin;

oracle> tkprof inputfile= tracedosyam.trc outputfile= selecttrace.trc sys=no table=schema.mytable


...
select max(column_name)
from mytable
where column_name=’Literal’


call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- -------
Parse 1 0.01 0.01 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.21 0.20 307 311 0 1
------- ------ -------- ---------- ---------- ---------- ---------- -------
total 4 0.22 0.11 307 311 0 1

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 31

Rows Row Source Operation
------- ---------------------------------------------------
1 SORT AGGREGATE (cr=307 pr=311 pw=0 time=52845 us)
77 TABLE ACCESS FULL MYTABLE (cr=307 pr=311 pw=0 time=11524 us)

Hiç yorum yok:

Yorum Gönder