遇到sql语句查询出错的问题.Yong Huang版提示做10046事件.对这个事件以前一直是模糊概念.想理清楚,所以写成这个文档.供以后使用.
You can think of the event 10046 “level” attribute associated with an Oracle session as a 4-bit flag whose bits have the following meanings:
Level |
Function | |
Decimal | Binary | |
1 | 0001 | Emit statistics for parse, execute, fetch, commit, and rollback database calls (standard sql_trace) |
2 | 0010 | Unknown |
3 | 0100 | Emit values for SQL bind variables (also called “placeholders”) |
4 | 1000 | Emit statistics for Oracle kernel internal function calls (also called “wait events”) listed in v$event_name |
For example, a level-12 trace combines the effects of level-4 and level-8 tracing. Strangely, activating any non-zero tracing level also activates level-1 tracing. Therefore, tracing at levels 4, 8, and 12 are exactly equivalent to tracing at levels 5, 9, and 13, respectively: all these levels include the standard sql_trace output.
SQL> show parameter diagnostic_dest
SQL> show parameter user_dump_dest
tracefile 命名规则 :<ORACLE_SID>_ora_<pid>_<tracedid>.trc
其中pid为相应session所对应的OS PID,tracedid 跟session的TRACEFILE_IDENTIFIER参数相关,默认TRACEFILE_IDENTIFIER为null.
eg.
给当前session设置TRACEFILE_IDENTIFIER
ALTER SESSION SET TRACEFILE_IDENTIFIER='TOMS';
此处的"TOMS"即为trace file 命名规则中<ORACLE_SID>_ora_<pid>_<tracedid>.trc的 tracedid.
可以设置TRACEFILE_IDENTIFIER参数的session里查询V$PROCESS.TRACEID查看tracefile_identifier的设置.
取消session标识将 tracefile_identifier置空即可.
alter session set tracefile_identifier='';
Normal
0
7.8 磅
0
2
false
false
false
EN-US
ZH-CN
X-NONE</w:LidThemeComplexScript.
MicrosoftInternetExplorer4
<style. /* Style. Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.5pt;
mso-bidi-font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-font-kerning:1.0pt;}
</style.
select d.value || '/' || lower(rtrim(i.instance, chr(0))) || '_ora_' || |
Normal
0
7.8 磅
0
2
false
false
false
EN-US
ZH-CN
X-NONE</w:LidThemeComplexScript.
MicrosoftInternetExplorer4
<style. /* Style. Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.5pt;
mso-bidi-font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-font-kerning:1.0pt;}
</style.
Normal 0 7.8 磅 0 2 false false false EN-US ZH-CN X-NONE</w:LidThemeComplexScript. MicrosoftInternetExplorer4 <style. /* Style. Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-font-kerning:1.0pt;} </style. Normal 0 7.8 磅 0 2 false false false EN-US ZH-CN X-NONE</w:LidThemeComplexScript. MicrosoftInternetExplorer4 <style. /* Style. Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-font-kerning:1.0pt;} </style. select
d.value || '/' || lower(rtrim(i.instance, chr(0))) || '_ora_' ||
|
会提示输入sid的数值.嘿嘿,就是把1给小小的改动了下.sid到v$session视图中查询.这里面的trace file名字是拼出来的.所以仅仅符合trace命名规则的<ORACLE_SID>_ora_<pid>.trc部分
|
conn / as sysdba |
conn / as sysdba |
connect / as sysdba |
connect / as sysdba |
记得把9834换成自己查询出来的OS PID
alter system set events '10046 trace name context forever,level 12'; |
alter system set events '10046 trace name context forever,level 12' scope=spfile; |
有些情况我们需要trace一个登录用户.这时可以通过trigger完成.
CREATE OR REPLACE TRIGGER SYS.set_trace |
注意登录用户必须拥有alter session权限才能成功trace.
grant alter session to <USERNAME> ; |
生成10046 trace仅仅是分析的第一步.后面还有好多分析要去学习.
疑问:
1.TRACEFILE_IDENTIFIER在某一个session中设置后,其他session怎么才能知道设置的TRACEFILE_IDENTIFIER值? session设置TRACEFILE_IDENTIFIER后,会在trace目录下有两个trace文件,一个含tracedid,一个不含.
2.dbms_system包的用法没找到.待解决.
Oracle System Performance Analysis Using Oracle Event 10046
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。