国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

了解raw trace文件的各項內容

2024-07-21 02:06:17
字體:
來源:轉載
供稿:網友

今天瀏覽metalink,看到這篇interpreting raw sql_trace,比較老的一篇文章了,但是確實很有用,所以決定大略翻譯一下吧。

我們知道有幾種方法可以得到一個sql語句執行時后臺的trace文件,一個是用sql_trace,一個是用dbms_support包或者dbms_system包,還有一種就是直接使用10046 event。

使用10046 event的方法大致如下:

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

your sql statement...

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

其中的level有1,4,8,12幾個選項,其中1相當于設置sql_trace=true之后的結果,4包括1的結果和綁定變量的實際值,8包括1的結果和等待事件的情況,12則同時包含1的結果,綁定變量的實際值和等待事件情況,所以可以說level 12是最為詳細的trace了。

同時我們也知道,對于trace結果,oracle提供了tkprof實用程序用來格式化trace文件,提供一份更容易讀懂的trace結果。

那么為什么還要直接讀取trace文件呢?最重要的是tkprof的結果是不包含綁定變量值的,同時也不包括真正的sql執行順序,而trace文件中我們則可以看到按照時間排列的parse,binds,executes,fetch等等,這在某西場合下是很有用處的。還有就是,如果你能夠直接讀取這些讓人看得眼暈的trace,是不是會有一種很爽,很大師的感覺:-)

當然如果我們要根據一些標準(比如cpu時長,磁盤讀取量等)進行trace中的sql排序,那么tkprof是我們唯一的選擇,可以參看coolyl的tkprof工具介紹和分析。

 

下面是metalink中的這篇文章的大體翻譯,大部分名詞用英文反而更好,就不強加翻譯了,相信大家都看得懂。當然也是比較懶的原因:-)

 

文本總結了trace結果原始輸出文件中的內容。

 

----------------------------------------------------------------------------

appname mod='%s' mh=%lu act='%s' ah=%lu

----------------------------------------------------------------------------

 

appname:application name setting。在oracle 7.2和以上版本中出現。這個名稱可以由dbms_application_info包來設定。

mod:module name

mh:module hash value

act:action

ah:action hash value

 

比如:appname mod='sql*plus' mh=3669949024 act='' ah=4029777240

 

----------------------------------------------------------------------------

parsing in cursor #<cursor> len=x dep=x uid=x oct=x lid=x tim=x hv=x ad='x'

<statement>

end of stmt

----------------------------------------------------------------------------

 

<cursor>:cursor number

len :length of sql statement,sql語句的長度

dep :recursive depth of the cursor,當前sql語句的遞規深度,如果為0則表示是用戶提交的sql,為1則是由于用戶sql而導致oracle后臺自己執行的sql,為2則是由1級sql繼續誘發的下一級sql。

uid :schema user id of parsing user

oct :oracle command type.

lid :privilege user id.

tim :timestamp。在oracle9i之前單位是1/100秒,9i則是1/1,000,000秒。利用這個值可以計算一個sql執行了到底多長時間。這個值就是當前行被寫入trace文件時數據庫v$timer視圖的值。

hv :hash id.

ad :sqltext address,sqltext的地址,跟v$sqlarea和v$sqltext視圖中的address字段值相等。

<statement> :the actual sql statement being parsed.

 

----------------------------------------------------------------------------

parse error #%d:len=%ld dep=%d uid=%ld oct=%d lid=%ld tim=%lu err=%d

<statement> ...

----------------------------------------------------------------------------

 

parse error :在oracle 7.2以上版本中解析的錯誤會寫入trace文件中。

len :length of sql statement.

dep :recursive depth of the statement

uid :user id.

oct :oracle command type (if known).

lid :privilege user id.

tim :timestamp.

err :oracle error code (e.g. ora-xxxxx) reported

<statement> :the sql statement that errored.

 

----------------------------------------------------------------------------

parse #<cursor>:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=0

exec #<cursor>:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=0

fetch #<cursor>:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=0

unmap #<cursor>:c=0,e=0,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=4,tim=0

----------------------------------------------------------------------------

 

parse :parse a statement. 解析一個sql

exec :execute a pre-parsed statement. 執行已經解析完畢的sql

fetch :fetch rows from a cursor. 從游標中得到數據,通常指select返回記錄

unmap :如果游標使用了臨時表(temporary table), 當游標關閉的時候將會看到unmap

c :cpu time (100th's of a second in oracle7 ,8 and 9).

e :elapsed time (100th's of a second oracle7, 8. microseconds in oracle 9 onwards).

p :number of physical reads.

cr :number of buffers retrieved for cr reads.

cu :number of buffers retrieved in current mode.

mis :cursor missed in the cache.

r :number of rows processed.

dep :recursive call depth (0 = user sql, >0 = recursive).

og :optimizer goal: 1=all_rows, 2=first_rows, 3=rule, 4=choose

tim :timestamp (large number in 100ths of a second).

 

比如:fetch #2:c=0,e=106,p=0,cr=3,cu=0,mis=0,r=1,dep=1,og=4,tim=6005498548671

 

----------------------------------------------------------------------------

error #%d:err=%d tim=%lu

----------------------------------------------------------------------------

 

執行或者fetch之后出現的sql error

err :oracle error code (e.g. ora-xxxxx) at the top of the stack.

tim :timestamp.

 

----------------------------------------------------------------------------

stat #<cursor> id=n cnt=0 [pid=0 pos=0 obj=0 op='sort aggregate ']

----------------------------------------------------------------------------

 

<cursor>的執行計劃.

<cursor> :cursor which the statistics apply to.

id :line of the explain plan which the row count applies to (從1開始).

cnt :number of rows for this row source.

pid :parent id of this row source.

pos :position in explain plan.

obj :object id of row source (if this is a base object).

op : the row source access operation.

 

比如:

stat #2 id=2 cnt=0 pid=1 pos=1 obj=510 op='table access by index rowid object_usage (cr=2 r=0 w=0 time=83 us)'

stat #2 id=3 cnt=1 pid=2 pos=1 obj=511 op='index range scan i_stats_obj# (cr=1 r=0 w=0 time=43 us)'

 

----------------------------------------------------------------------------

xctend rlbk=%d rd_only=%d

----------------------------------------------------------------------------

 

xctend是事務結束的標志.

rlbk :1 if a rollback was performed, 0 if no rollback (commit).

rd_only :1 if transaction was read only, 0 if changes occurred.

 

----------------------------------------------------------------------------

binds #%d:

bind 0: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=03 oacfl2=0 size=24 offset=0

bfp=02fedb44 bln=22 avl=00 flg=05

value=10

----------------------------------------------------------------------------

 

bind :variables bound to a cursor.

bind n :the bind position being bound.

dty :data type.

mxl :maximum length of the bind variable (private max len in paren).

mal :array length.

scl :scale.

pre :precision.

oacflg :special flag indicating bind options

oacflg2 :continuation of oacflg

size :amount of memory to be allocated for this chunk

offset :offset into this chunk for this bind buffer

bfp :bind address.

bln :bind buffer length.

avl :actual value length (array length too).

flg :special flag indicating bind status

value :the actual value of the bind variable.

 

比如:

binds #4:

 bind 0: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=08 oacfl2=1 size=24 offset=0

   bfp=ffffffff7ce64ee0 bln=22 avl=01 flg=05

   value=0

 bind 1: dty=1 mxl=32(11) mal=00 scl=00 pre=00 oacflg=18 oacfl2=1 size=32 offset=0

   bfp=ffffffff7ce6b128 bln=32 avl=11 flg=05

   value="tabcompart$"

 bind 2: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=08 oacfl2=1 size=24 offset=0

   bfp=ffffffff7ce6bae8 bln=24 avl=02 flg=05

   value=1

 

----------------------------------------------------------------------------

wait #<cursor>: nam="<event name>" ela=0 p1=0 p2=0 p3=0

----------------------------------------------------------------------------

 

wait :an event that we waited for.

nam :what was being waited for.

ela :elapsed time for the operation.

p1 :p1 for the given wait event.

p2 :p2 for the given wait event.

p3 :p3 for the given wait event.

 

比如 (full table scan):

wait #1: nam="db file scattered read" ela= 5 p1=4 p2=1435 p3=25

在游標1上經歷了"db file scattered read"等待事件,一共等了0.05秒,在讀取file 4,從1435 block開始,讀了25個block

 

比如 (index scan):

wait #1: nam="db file sequential read" ela= 4 p1=4 p2=1224 p3=1

在游標1上經歷了"db file sequential read"等待事件,一共等了0.04秒,在讀取file 4,block 1224,讀取了這一個block

 

對于每一個等待事件的含義和p1,p2,p3表示的意思,可以參考oracle database reference文檔的oracle wait events章節。

 

商業源碼熱門下載www.html.org.cn

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 枣庄市| 蛟河市| 闽清县| 金堂县| 富蕴县| 丰宁| 临桂县| 香河县| 潍坊市| 柏乡县| 平湖市| 罗源县| 冀州市| 综艺| 巢湖市| 锡林浩特市| 筠连县| 明溪县| 西丰县| 格尔木市| 阳朔县| 白朗县| 澳门| 丹巴县| 漳州市| 北川| 永修县| 黄山市| 内黄县| 庐江县| 文水县| 伊宁市| 永靖县| 潜江市| 建阳市| 蒙山县| 微山县| 荥阳市| 安阳市| 敖汉旗| 长顺县|