Raw Trace的收集方法
1. 打开Trace,Help > Diagnostics > Trace > Trace > Trace with Binds and Waits
Trace项代表的意思
- No Trace – turns trace off.
- Regular Trace – generates a regular SQL trace by performing the following statement:
ALTER SESSION SET SQL_TRACE = TRUE;
- Trace with Binds – writes bind variable values in the SQL trace file
- Trace with Waits – writes wait events in the SQL trace file
- Trace with Binds and Waits – writes both bind variable values and wait events in the SQL trace file
2.执行业务功能
3.关闭Trace,Help > Diagnostics > Trace > Trace > No Trace
系统会弹出一个窗口,告诉你Trace文件所在的目录。
这个目录实际上是数据库系统参数表(v$parameter)中的user_dump_dest的值,可以执行下边的SQL来找到Trace文件所在的目录
trace文件名后边的那个数字是Database Server PID,也可以从Help>About中找到。
TKPROF
之前我们收集的trace日志仍为Raw Trace,如果要做性能分析的话,往往要转换为TKPROF,TKPROF可以把Raw Trace转换为更易读的形式。
tracefile:你要分析的trace文件
outputfile:格式化后的文件
explain=user/password@connectstring
table=schema.tablename
注1:这两个参数是一起使用的,通过连接数据库对在trace文件中出现的每条sql语句查看执行计划,并将之输出到outputfile中
注2:该table必须是数据库中不存在的,如果存在会报错
print=n:只列出最初N个sql执行语句
insert=filename:会产生一个sql文件,运行此文件可将收集到的数据insert到数据库表中
sys=no:过滤掉由sys执行的语句
record=filename:可将非嵌套执行的sql语句过滤到指定的文件中去
waits=yes|no:是否统计任何等待事件
aggregate=yes|no:是否将相同sql语句的执行信息合计起来,默认为yes
sort=option:设置排序选项,选项如下:
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
转载请注明出处:http://blog.csdn.net/pan_tian/article/details/7677120