sitemap

RSS地图

收藏本站

设为首页

Oracle研究中心

当前位置:Oracle研究中心 > 运维DBA >

【学习笔记】Oracle 使用TKPROF格式化分析ORACLE跟踪文件

时间:2016-06-28 09:35   来源:Oracle研究中心   作者:惜分飞   点击:

天萃荷净 TKPROF使用,Tkprof是一个分析ORACLE跟踪文件并且产生一个更加人性化清晰的输出结果的可执行工具

1、设置sql跟踪

--系统级别
alter system set sql_trace=true;
alter system set sql_trace=false;
--会话级别
alter session set sql_trace=true;
alter session set sql_trace=false;
--其他会话
exec sys.dbms_system.set_sql_trace_in_session(16737 , 39196 , true);
exec sys.dbms_system.set_sql_trace_in_session(16737 , 39196 , false);

2、执行相关sql语句
需要跟踪的sql

3、查询trace 文件

select d.value||'/'||lower(rtrim(i.instance,chr(0)))||'_ora_'||p.spid||'.trc' trace_file_name from 
(select p.spid from v$mystat m, v$session s,v$process p where m.statistic# = 1 and s.sid = m.sid and p.addr = s.paddr ) p,
(select t.instance from v$thread t,v$parameter v where v.name = 'thread' and(v.value = 0 or t.thread# = to_number(v.value))) i,
(select value from v$parameter where name = 'user_dump_dest') d

4、使用TKPROF命令

tkprof trace_file_name out_file explain=username/password
TKPROF DLSUN12_JANE_FG_SVRMGR_007.TRC OUTPUTA.PRF
EXPLAIN=SCOTT/TIGER TABLE=SCOTT.TEMP_PLAN_TABLE_A
INSERT=STOREA.SQL SYS=NO SORT=(EXECPU,FCHCPU)

5、排序选项说明
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


--------------------------------------ORACLE-DBA----------------------------------------

最权威、专业的Oracle案例资源汇总之【学习笔记】Oracle 使用TKPROF格式化分析ORACLE跟踪文件

本文由大师惜分飞原创分享,网址:http://www.oracleplus.net/arch/606.html

Oracle研究中心

关键词:

使用TKPROF格式化分析ORACLE跟踪文件

TKPROF使用案例