oracle session(會話) 跟蹤
開啟跟蹤事件
開啟10046事件並設定級別為4:alter session set events '10046 trace name context forever, level 4';
關閉10046事件:alter session set events '10046 trace name context off';
檢視尋10046生成的trace檔案
select value from v$diag_info where name='Default Trace File';
用下面的方法對其他會話進行跟蹤:
SQL_TRACE:
獲取想要跟蹤session的sid:select distinct sid from v$mystat;
獲得需要trace會話的SID和serial#的值:select sid, serial# from v$session where sid=[SID];
啟動SQL_TRACE: execute dbms_system.set_sql_trace_in_session([SID],[seial#],true); 需要sysdba許可權
停止SQL_TRACE: execute dbms_system.set_sql_trace_in_session([SID],[seial#],false); 需要sysdba許可權
10046事件:
獲得需要trace會話的SID和serial#的值:select sid, serial# from v$session where sid=[SID];
啟動SQL_TRACE: execute dbms_monitor.session_trace_enable([SID],[seial#],waits=>true,binds=>true);
停止SQL_TRACE: exec dbms_monitor.session.trace_disable([SID],[seial#]);
其中, 10046 按照收集資訊的內容分為以下等級:
Level 0 停用SQL跟蹤,相當於SQL_TRACE=FALSE
Level 1 標準SQL跟蹤,相當於SQL_TRACE=TRUE
Level 4 在level 1的基礎上增加繫結變數的資訊
Level 8 在level 1的基礎上增加等待事件的資訊
Level 12 在level 1的基礎上增加繫結變數和等待事件的資訊
PARSING IN CURSOR #140397889619520 len=70 dep=1 uid=0 oct=3 lid=0 tim=1495445064661679 hv=3849548163 ad='887f8898' sqlid='53saa2zkr6wc3'
cursor cursor number
len sql 語句長度
dep sql 語句遞迴深度
uid user id
oct oracle command type
lid privilege user id
tim timestamp,時間戳
hv hash id
ad sql address 地址, 用在 v$sqltext
sqlid sql id
EXEC #140397889619520:c=0,e=110,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=4,plh=1514015273,tim=1495445064661771
WAIT #140397889619520: nam='db file sequential read' ela= 652 file#=1 block#=79197 blocks=1 obj#=58 tim=1495445064662479
FETCH #140397889619520:c=4998,e=783,p=1,cr=3,cu=0,mis=0,r=1,dep=1,og=4,plh=1514015273,tim=1495445064662578
c CPU 消耗的時間
e Elapsed time
p number of physical reads 物理讀的次數
cr number of buffers retrieved for CR reads 邏輯讀的資料塊
cu number of buffers retrieved in current mode (current 模式讀取的資料塊)
mis cursor missed in the cache 庫快取中丟失的遊標, 硬解析次數
r number of rows processed 處理的行數
dep 遞迴深度
og optimizer mode 【1:all_rows, 2:first_rows, 3:rule, 4:choose】
plh plan hash value
tim timestamp 時間戳
WAIT #140397889619520: nam='db file sequential read' ela= 652 file#=1 block#=79197 blocks=1 obj#=58 tim=1495445064662479
nam an event that we waited for 等待事件
ela 此操作消耗的時間
p3 block 塊號
trm timestamp 時間戳
STAT #140397883926128 id=1 cnt=1 pid=0 pos=1 obj=22 op='TABLE ACCESS BY INDEX ROWID USER$ (cr=2 pr=0 pw=0 time=29 us cost=1 size=104 card=1)'
cnt 當前行源返回的行數
pid parent id of this row source 當前行源的父結點 id
pos position in explain plan 執行計劃的位置
obj object id of row source (if this is a base object)
op the row source access operation
例如, 執行步驟 TABLE ACCESS BY INDEX ROWID 消耗的邏輯讀為 2, 物理讀為 0, 耗費的時間為 29 us, 成本 cost 1,返回 1 條記錄
使用 tkprof 命令翻譯 trace 檔案
我們也可以使用 tkprof 命令對 trace 檔案進行翻譯,得到一個容易理解的 trace 彙總報表檔案
tkprof 1.txt 1.out
注意:Misses in library cache during parse: 1 意思是解析的時候庫快取丟失遊標, 也就是說發生了一次硬解析
開啟10046事件並設定級別為4:alter session set events '10046 trace name context forever, level 4';
關閉10046事件:alter session set events '10046 trace name context off';
檢視尋10046生成的trace檔案
select value from v$diag_info where name='Default Trace File';
用下面的方法對其他會話進行跟蹤:
SQL_TRACE:
獲取想要跟蹤session的sid:select distinct sid from v$mystat;
獲得需要trace會話的SID和serial#的值:select sid, serial# from v$session where sid=[SID];
啟動SQL_TRACE: execute dbms_system.set_sql_trace_in_session([SID],[seial#],true); 需要sysdba許可權
停止SQL_TRACE: execute dbms_system.set_sql_trace_in_session([SID],[seial#],false); 需要sysdba許可權
10046事件:
獲得需要trace會話的SID和serial#的值:select sid, serial# from v$session where sid=[SID];
啟動SQL_TRACE: execute dbms_monitor.session_trace_enable([SID],[seial#],waits=>true,binds=>true);
停止SQL_TRACE: exec dbms_monitor.session.trace_disable([SID],[seial#]);
其中, 10046 按照收集資訊的內容分為以下等級:
Level 0 停用SQL跟蹤,相當於SQL_TRACE=FALSE
Level 1 標準SQL跟蹤,相當於SQL_TRACE=TRUE
Level 4 在level 1的基礎上增加繫結變數的資訊
Level 8 在level 1的基礎上增加等待事件的資訊
Level 12 在level 1的基礎上增加繫結變數和等待事件的資訊
PARSING IN CURSOR #140397889619520 len=70 dep=1 uid=0 oct=3 lid=0 tim=1495445064661679 hv=3849548163 ad='887f8898' sqlid='53saa2zkr6wc3'
cursor cursor number
len sql 語句長度
dep sql 語句遞迴深度
uid user id
oct oracle command type
lid privilege user id
tim timestamp,時間戳
hv hash id
ad sql address 地址, 用在 v$sqltext
sqlid sql id
EXEC #140397889619520:c=0,e=110,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=4,plh=1514015273,tim=1495445064661771
WAIT #140397889619520: nam='db file sequential read' ela= 652 file#=1 block#=79197 blocks=1 obj#=58 tim=1495445064662479
FETCH #140397889619520:c=4998,e=783,p=1,cr=3,cu=0,mis=0,r=1,dep=1,og=4,plh=1514015273,tim=1495445064662578
c CPU 消耗的時間
e Elapsed time
p number of physical reads 物理讀的次數
cr number of buffers retrieved for CR reads 邏輯讀的資料塊
cu number of buffers retrieved in current mode (current 模式讀取的資料塊)
mis cursor missed in the cache 庫快取中丟失的遊標, 硬解析次數
r number of rows processed 處理的行數
dep 遞迴深度
og optimizer mode 【1:all_rows, 2:first_rows, 3:rule, 4:choose】
plh plan hash value
tim timestamp 時間戳
WAIT #140397889619520: nam='db file sequential read' ela= 652 file#=1 block#=79197 blocks=1 obj#=58 tim=1495445064662479
nam an event that we waited for 等待事件
ela 此操作消耗的時間
p3 block 塊號
trm timestamp 時間戳
STAT #140397883926128 id=1 cnt=1 pid=0 pos=1 obj=22 op='TABLE ACCESS BY INDEX ROWID USER$ (cr=2 pr=0 pw=0 time=29 us cost=1 size=104 card=1)'
cnt 當前行源返回的行數
pid parent id of this row source 當前行源的父結點 id
pos position in explain plan 執行計劃的位置
obj object id of row source (if this is a base object)
op the row source access operation
例如, 執行步驟 TABLE ACCESS BY INDEX ROWID 消耗的邏輯讀為 2, 物理讀為 0, 耗費的時間為 29 us, 成本 cost 1,返回 1 條記錄
使用 tkprof 命令翻譯 trace 檔案
我們也可以使用 tkprof 命令對 trace 檔案進行翻譯,得到一個容易理解的 trace 彙總報表檔案
tkprof 1.txt 1.out
注意:Misses in library cache during parse: 1 意思是解析的時候庫快取丟失遊標, 也就是說發生了一次硬解析
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30345407/viewspace-2139701/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle跟蹤會話Oracle會話
- 使用dbms_monitor.session_trace_enable跟蹤一個會話Session會話
- 會話跟蹤技術會話
- 給會話開跟蹤會話
- 會話級SQL跟蹤會話SQL
- oracle 跟蹤當前使用者會話Oracle會話
- oracle10g會話跟蹤處理Oracle會話
- 用oracle trace 來跟蹤sessionOracleSession
- alter session set events /Oracle跟蹤SessionOracle
- 用Oracle跟蹤診斷掛起的會話Oracle會話
- 會話跟蹤技術Cookieless會話Cookie
- Oracle 會話(Session)Oracle會話Session
- 用oracle trace 來跟蹤session 活動OracleSession
- 10046 跟蹤其他會話會話
- -t【Oracle-故障管理】-Trace跟蹤會話和會話執行慢故障分析Oracle會話
- 10046事件跟蹤會話sql事件會話SQL
- 關於oracle中session跟蹤的總結OracleSession
- 玩轉跟蹤(to owner session、other session)Session
- 【會話】Oracle kill session系列會話OracleSession
- 對session進行跟蹤Session
- Oracle SQL 跟蹤 --- dbms_system.set_sql_trace_in_sessionOracleSQLSession
- web前端學習教程:Cookie會話跟蹤技術Web前端Cookie會話
- Session會話Session會話
- 跟蹤session 與 trace檔案分析Session
- 跟蹤SESSION 與 trace 檔案解析Session
- [zt] oracle跟蹤檔案與跟蹤事件Oracle事件
- oracle跟蹤檔案與跟蹤事件(zt)Oracle事件
- oracle跟蹤檔案和跟蹤事件(zt)Oracle事件
- ORACLE 跟蹤工具Oracle
- HTML5入門教程 :Cookie會話跟蹤技術HTMLCookie會話
- 利用sql_trace跟蹤一個指定會話的操作SQL會話
- 會話的跟蹤以及執行計劃的獲取會話
- session跟蹤失效的問題和原因Session
- 使用sqltrace跟蹤session執行的sqlSQLSession
- 【TRACE】Oracle跟蹤事件Oracle事件
- Oracle 跟蹤事件【轉】Oracle事件
- Oracle跟蹤檔案Oracle
- oracle 會話(session)被鎖瞭解決方法Oracle會話Session