话说oracle的剖析工具有很多,这里就介绍下常用的tkprof剖析工具。
敲tkprof回车,可以看到提示
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
参数是挺多的,这里拣几个常用的理解一下吧
explain这里需要输入用户名和密码 ,explain=user/password,得到执行计划和行源信息
table 指定保存执行计划的表
aggregate 是否单独处理同样内容的SQL
waits等待事件是否加入到输出文件
sort指定输出文件的SQL顺序
sys=no 就是不看系统的SQL
参数就介绍这些,下面我们介绍下怎么阅读输出的文本信息,这个才是关键,一般都是udump下的trace文件
tkprof skyread_ora_10409.trc /home/oracle/0818.txt sort=prsela,exeela,fchela print=3 explain=yypt/yypt aggregate=no sys=no