Oracle SQL Trace 和 10046 事件跟踪(十)

2014-11-24 18:26:01 · 作者: · 浏览: 12
1 TABLE ACCESS BY INDEX ROWID OBJ$ (cr=3 r=0 w=0 time=24 us)
1 INDEX UNIQUE SCAN I_OBJ1 (cr=2 r=0 w=0 time=12 us)(object id 33)
********************************************************************************
在report.txt文件头有各个数据的解释,根据以下一些指标可以分析一下SQL的执行性能:  
(query+current)/rows 平均每行所需的block数,太大的话(超过20)SQL语句效率太低
Parse count/Execute count parse count应尽量接近1,如果太高的话,SQL会进行不必要的reparse。要检查Pro*C程序的MAXOPENCURSORS是不是太低了,或不适当的使用的RELEASE_CURSOR选项  
rows Fetch/Fetch Fetch Array的大小,太小的话就没有充分利用批量Fetch的功能,增加了数据在客户端和服务器之间的往返次数。在Pro*C中可以用prefetch=NN,Java/JDBC中可调用SETROWPREFETCH,在PL/SQL中可以用BULK COLLECT,SQLPLUS中的arraysize(缺省是15)
disk/query+current 磁盘IO所占逻辑IO的比例,太大的话有可能是db_buffer_size过小(也跟SQL的具体特性有关)
elapsed/cpu 太大表示执行过程中花费了大量的时间等待某种资源
cpu OR elapsed 太大表示执行时间过长,或消耗了大量的CPU时间,应该考虑优化
执行计划中的Rows 表示在该处理阶段所访问的行数,要尽量减少
整合.trc文件:
tkprof *.trc /file/ora_trc/ora_trc.txt explain=username/pwd sys=no insert=/file/ora_trc/insert.sql record=/file/ora_trc/record.txt aggregate=no waits=yes


tkprof的参数有下面几个:  
explain=username/password -> connect to oracle and issue explain plain
talbe=schema.tablename -> use'schema.table' with explain option
aggregate=yes/no
insert=filename -> list sql statements and
disk/query+current 磁盘IO所占逻辑IO的比例,太大的话有可能是db_buffer_size过小(也跟SQL的具体特性有关)
elapsed/cpu 太大表示执行过程中花费了大量的时间等待某种资源
cpu OR elapsed 太大表示执行时间过长,或消耗了大量的CPU时间,应该考虑优化
执行计划中的Rows 表示在该处理阶段所访问的行数,要尽量减少
整合.trc文件:
tkprof *.trc /file/ora_trc/ora_trc.txt explain=username/pwd sys=no insert=/file/ora_trc/insert.sql record=/file/ora_trc/record.txt aggregate=no waits=yes
tkprof的参数有下面几个:  
explain=username/password -> connect to oracle and issue explain plain
talbe=schema.tablename -> use'schema.table' with explain option
aggregate=yes/no
insert=filename -> list sql statements anddatainside 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

print=integer -> list only the first 'integer' sql statements
sort=option -> set zero or more of the following sort options
option详细参数:
Sort Option Description
-------------- ------------------------------------------------
execnt number of execute was called
execpu cpu time spent executing
execu number of buffers for current read during execute
exedsk number of disk reads during execute
exeela elapsed time executing
exemis number of library cache misses during execute
exeqry number of buffers for consistent read during execute
exerow number of rows processed during execute
fchcnt number of times fetch was called
fchcpu cpu time spent fetching
fchcu number of buffers for current read during fetch
fchdsk number of disk reads during fetch
fchela elapsed time fetching
fchqry number of buffers for consistent read during fetch
fchrow number of rows fetched
prscnt number of times parse was called
prscpu cpu time parsing
prscu number of buffers for current read during parse
prsdsk number of disk reads during parse
prsela elapsed time parsing
prsmis number of misses in library cache during parse
prsqry number of buffers for consistent read during parse
userid userid of user that parsed the cursor
sys=no -> tkprof does not list sql statements run as user sys.
re