ITPub博客

首页 > 数据库 > Oracle > oracle 10046跟踪详细步骤

oracle 10046跟踪详细步骤

原创 Oracle 作者:wanglinghua0907 时间:2024-01-29 17:04:46 0 删除 编辑

跟踪会话的级别

Level 1:跟踪SQL语句,等于sql_trace=true

Level 4:包括变量的详细信息

Level 8:包括等待事件

Level 12:包括绑定变量与等待事件

16  在11g中为每一次执行生成STAT信息,仅在11.1之后可用

32  比level 1少执行计划

64  和level 1 相比 在第一次执行后还可能生成执行计划信息 ; 条件是某个游标在前一次执行的前提下 运行耗时变长了一分钟。仅在 11.2.0.2中可用

Level 28 (4 + 8 + 16) 代表 同时启用 level 4 、level 8、level 16

level 68 ( 64 + 4 )  代表 同时启用 level 64、level 4


当前会话

1.开启10046跟踪

alter session set events '10046 trace name context forever,level 12';


2.设置trace的标识

alter session set tracefile_identifier='feng'


3.执行sql

xxxxxxx


4.关闭10046跟踪

alter session set events '10046 trace name context off';


5.定位此次的trace文件位置

select distinct(m.sid),p.pid,p.tracefile from v$mystat m,v$session s,v$process p where m.sid=s.sid and s.paddr=p.addr;


6.输出

tkprof orcl_ora_3576_feng.trc orcl_ora_3576_feng.txt


其他会话

查出spid和pid

select spid,pid from v$process where addr in (select paddr from v$session where sid=(要查的sid));


SPID PID

----- ----

57994 63


选定spid

Oradebug setospid 57994


取消对trace文件大小的限制

Oradebug unlimit;


开启10046

oradebug event 10046 trace name context forever,level 12;


查看trace地址

oradebug tracefile_name;


转化trace文件

tkprof orcl_ora_3576_feng.trc orcl_ora_3576_feng.txt


关闭10046(一定要关闭)

Oradebug event 10046 trace name context off;


参数介绍

count = OCI过程执行的次数 

CPU = CPU时间,以秒为单位执行 

Elapsed =以秒为单位的执行时间 

Disk =从磁盘读取缓冲区的物理次数 

Query =为一致性读取而获得的缓冲区数量 

Current =在当前模式下获得的缓冲区数量(通常用于更新) 

Rows =由取回或执行调用处理的行数


例子:

部分内容

Plain Text v SQL ID: f63rfdamawhv2 Plan Hash : 105285479 e.es 526. 17 526.63 526.27 526.75 select ts#, file#, f rom seg$ where type* block* cpu call Parse Execute Fetch total count 2e1e 2818 2810 se3e elapsed disk e e query 5273637e 5273637e current rows zele 2e1e Misses in library cache during parse: 1 Optimizer mode: CHOOSE parsing user SYS (recursive depth: Number Of plan statistics captured: 3 Rows (1st) Rows (avg) Rows (max) 1 Row Source Operation TABLE ACCESS FULL SEG$ (crz2S237 pr=e pwze time-429271 us cost-5177 sizez16 card-I)


递归深度2。 (如果为0就是非递归sql。来自外部(普通SQL)还来自数据库本身(递归SQL)。jdbc也算非递归。

SQL ID: db78fxqxwxt7r Plan Hash: 331242øø81 select rule bucket, endpoint, col#, epvalue from histgrn$ where and and order by bucket call Parse Execute Fetch total count 123 123 247 cpu e. 01 elapsed ø.øø query e 382 382 current 1879 1879 Misses in library cache during parse: I Misses in library cache during execute Optimizer mode: RULE Parsing user id: SYS recursive de th: 2 Number of plan statistics captur ROWS (1st) ROWS (avg) ROWS (max) 1 1 1 ROW Source Operation SORT ORDER BY (cr-3 prae pw-e time-se us cost-e size-ø card-a) TABLE ACCESS CLUSTER HISTGRM$ pr=e time-76 us) INDEX UNIQUE SCAN (cr=2 pr=e pw=e time-51 id 445)


总体所有递归语句汇总和 非递归语句汇总

Misses in library cache during parse • Elapsed tines include waiting on following events: OVERALL call Parse Execute Fetch total 69.eø e.el TOTALS count FOR ALL um-RECURSIVE elapsed C pu e.e3 e.e3 e. 17 e.e2 e.e2 e.27 STATEMENTS disk que ry Cu rrent Event waited on SQL •Net message to client SQL •Net message from client SQL *Net break 'reset to client Disk file operations I/O file sequential read db file sequential read rdbms ipc reply Data file init write control file parallel write db file single write Max. Wait Ha it ed Total Waited 243.81 e. el e. el local write wait log file Sync OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS call parse Execute Fetch total count 1276 233e 3972 cpu elapsed e.e7 e .11 e.22 disk que ry 5292 5772 current Misses in library cache during parse: 1B Misses in library cache during execute: 74 Elapsed times include waiting on following events: 3557 3587 Total Waited 11.93 Event waited on SQL •Net message to client SQL •Net message from client SQL *Net break/reset to client Disk file operations I/O db file sequential read 3e user SQL statements in session. 152 internal SQL statements in session. 182 SQL statements in session. Trace file: feng.trc Trace file compatibility: 11.1.e.7 Sort options: default session in tracefile. T imes ited Max. Wait 11.93 3B 152 182 11B 21462 256 user SQL statements in trace file. internal SQL statements in trace file. SQL statements in trace file. unique SQL statements in trace file. lines in trace file. elapsed seconds in trace file.




来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69980685/viewspace-3005612/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle ACE、sql server、oceanbase数据库专家,拥有7年以上的大型数据库运维经验,主方向oracle,擅长故障排除、诊断,大体量(TB)迁移,异常故障修复等。拥有丰富主导大型项目经验。服务行业包括:运营商、银行、金融业、政府单位、医疗、制造业、高校等等。

注册时间:2020-07-31

  • 博文量
    116
  • 访问量
    88779