oracle工具:tkprof简析(二)

2014-11-24 15:16:08 · 作者: · 浏览: 1
⑶ udump路径找到生成的trc文件
⑷ 对trc文件进行tkprof分析
tkprof tracefile outfile [options]
注意:这条语句后面没有分号结尾!!
5案例
[sql]
18:32:55 hr@ORCL (^ω^) alter session set events '10046 trace name context forever,level 12';
会话已更改。
18:34:00 hr@ORCL (^ω^) select count(*) from t;
COUNT(*)
----------
2
18:34:00 hr@ORCL (^ω^) update t1 set tname='think high' where id=1;
www.2cto.com
已更新 1 行。
18:34:30 hr@ORCL (^ω^) alter session set events '10046 trace name context off';
会话已更改。
18:34:55 hr@ORCL (^ω^) exit
D:\oracle\product\10.2.0\admin\orcl\udump>tkprof orcl_ora_6004.trc C:\Users\Administrator\tkprof_starting.txt sys=no waits=yes sort=fche
TKPROF: Release 10.2.0.1.0 - Production on 星期日 9月 23 19:19:13 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
这个tkprof文件最后的一部分如下:
[sql]
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
www.2cto.com
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 11 0.03 0.16 0 0 0 0
Execute 41 0.07 0.22 0 0 0 0
Fetch 48 0.03 0.12 3 118 0 50
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 100 0.14 0.51 3 118 0 50
Misses in library cache during parse: 11
Misses in library cache during execute: 11
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file sequential read 3 0.02 0.05
3 user SQL statements in session.
41 internal SQL statements in session.
44 SQL statements in session.
********************************************************************************
Trace file: orcl_ora_6004.trc
Trace file compatibility: 10.01.00
Sort options: fchela
1 session in tracefile.
3 user SQL statements in trace file.
41 internal SQL statements in trace file.
44 SQL statements in trace file.
14 unique SQL statements in trace file.
902 lines in trace file.
55 elapsed seconds in trace file.
www.2cto.com
注释:
① 这个session共有44条sql语句在里面,对于递归的语句一共分析了41次
② 计算hit ratio
logical reads=consistent gets+ db block gets
consistent gets=query列的execute+query列的fetch
db block gets=current列的execute+current列的fetch
因此,logical reads=118+0+0+0=118
physical reads=disk列,即:3
所以,hit ratio=L/(L+P)=97.5%
③ 还有一对参数非常重要,fetch的次数以及取得的记录的行数,一般来说,以尽可能少的fetch来取得尽可能多的记录数
,也就是,fetch的值要远远小于取得的记录数才好。从上面这个例子可知,fetch了48,rows 50,这表明
有些记录是通过好几次的fetch才得到的。这个session的有些sql是需要优化的。
④ 从query列的parse可以看出从row cache里读取的数据
这个tkprof文件中两个sql语句摘入如下:
[sql]
********************************************************************************
select count(*)
from
t www.2cto.com
call count cpu elapsed disk query c