首页 > 应用开发 > IT综合 > tkprof 转换trc文件
需要调整的语句符合以下几点:
(1),CPU占用过多
(2),Parse,Execute,Fetch花费太多时间
(3),DISK读取太多,query/current(SGA)中数据块读取太少
(4),访问许多块,只返回2行
=============================
使用tkprof格式化trace文件
Usage: tkprof tracefile outputfile [explain= ] [table= ] [print= ] [insert= ] [sys= ] [sort= ]
输入文件 格式化后的输出文件
table=schema.tablename Use 'schema.tablename' with 'explain=' option.
用于指定在将执行规划写进输出文件之前,TKPROF用于临时存放执行规划所用表的架构和名称
explain=user/password Connect to ORACLE and issue EXPLAIN PLAN.
print=integer List only the first 'integer' SQL statements. 只列出输出文件中的第一个INTEGER的SQL语句,若忽略,则TKPROF将列出所有跟踪的SQL语句
aggregate=yes|no 若用户指定AGGREGATE=NO,TKPROF将不会对相同SQL文本的多个用户进行汇总
insert=filename List SQL statements and data inside INSERT statements. SQL脚本的一种,用于将跟踪文件的动机信息存储到数据库中
sys=no TKPROF does not list SQL statements run as user SYS. 于启动或禁止将用户SYS所发布的SQL语句列表到输出文件之中,也包括递归SQL(为执行用户的SQL语句,ORACLE还必须执行一些附加语句)语句在内。默认为YES
record=filename Record non-recursive statements found in the trace file. 对于跟踪文件中的所用非递归SQL语句,TKPROF 将以指定的名称来创建某个SQL脚本。用于对跟踪文件中的用户时间进行重放
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: 在将被跟踪的SQL语句列表输出到跟踪文件之前,先将其按照指定排序选项的降序关系对其进行排序;若指定了多种排序选项,那么根据排序选项所指定值的和的降序关系对其进行排序;若忽略此参数,那么TKPROF将按照使用次序把语句列表到输出文件中
prscnt number of times parse was called 语句解析的数目
prscpu cpu time parsing 语句解析所占用的CPU时间
prsela elapsed time parsing 语句解析所占用的时间(总是大于或等于CPU时间);
prsdsk number of disk reads during parse 语句解析期间,从磁盘进行物理读取的数目
prsqry number of buffers for consistent read during parse 语句解析期间,一致模式块读取(CONSISTENT MODE BLOCK READ)的数目
prscu number of buffers for current read during parse 语句解析期间,当前模式读取(CURRENT MODE BLOCK READ)的数目
prsmis number of misses in library cache during parse 语句解析期间,库缓存失败的数目
execnt number of execute was called 语句执行的数目
execpu cpu time spent executing 语句执行所占用的CPU时间
exeela elapsed time executing 语句执行所占用的时间(总是大于或等于CPU时间)
exedsk number of disk reads during execute 语句执行期间,从磁盘进行物理读取的数目
exeqry number of buffers for consistent read during execute 语句执行期间,一致模式块读取(CONSISTENT MODE BLOCK READ)的数目
execu number of buffers for current read during execute 语句执行期间,当前模式读取(CURRENT MODE BLOCK READ)的数目
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 取数据所占用的CPU时间
fchela elapsed time fetching 取数据所占用的时间(总是大于或等于CPU时间)
fchdsk number of disk reads during fetch 取数据期间,从磁盘进行物理读取的数目
fchqry number of buffers for consistent read during fetch 取数据期间,一致模式块读取(CONSISTENT MODE BLOCK READ)的数目
fchcu number of buffers for current read during fetch 取数据期间,当前模式读取(CURRENT MODE BLOCK READ)的数目
fchrow number of rows fetched 所获取的行数
userid userid of user that parsed the cursor
------------------------------------------------
SELECT a.VALUE||b.symbol||c.instance_name||'_ora_'||d.spid||'.trc' TRACE_FILE_NAME
FROM (SELECT VALUE FROM v$parameter WHERE NAME='user_dump_dest') a,
(SELECT SUBSTR(VALUE,-6,1) symbol FROM v$parameter WHERE NAME='user_dump_dest') b,
(SELECT instance_name FROM v$instance) c,
(SELECT spid FROM v$session s,v$process p,v$mystat m
WHERE s.paddr=p.addr AND s.SID=m.SID AND m.statistic#=0) d
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8337095/viewspace-1033402/ ,如需转载,请注明出处,否则将追究法律责任。