您好,登錄后才能下訂單哦!
遇到sql語句查詢出錯的問題.Yong Huang版提示做10046事件.對這個事件以前一直是模糊概念.想理清楚,所以寫成這個文檔.供以后使用.
You can think of the event 10046 “l(fā)evel” 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 命名規(guī)則 :<ORACLE_SID>_ora_<pid>_<tracedid>.trc
其中pid為相應session所對應的OS PID,tracedid 跟session的TRACEFILE_IDENTIFIER參數(shù)相關,默認TRACEFILE_IDENTIFIER為null.
eg.
給當前session設置TRACEFILE_IDENTIFIER
ALTER SESSION SET TRACEFILE_IDENTIFIER='TOMS';
此處的"TOMS"即為trace file 命名規(guī)則中<ORACLE_SID>_ora_<pid>_<tracedid>.trc的 tracedid.
可以設置TRACEFILE_IDENTIFIER參數(shù)的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的數(shù)值.嘿嘿,就是把1給小小的改動了下.sid到v$session視圖中查詢.這里面的trace file名字是拼出來的.所以僅僅符合trace命名規(guī)則的<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
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。