Oracle動態效能檢視學習筆記(10)_v$session_wait

gdutllf2006發表於2010-07-26
Oracle動態效能檢視學習筆記(10)_v$session_wait

目錄

參考文件<>Chapter 24


##################################################################
1 Overview
##################################################################
This is a key view for finding botlenecks.
It tells what every session in the database is currently waiting for
(or the last event waited for by the session if it is not waiting for anything).
This view can be used as a starting point to find which direction to proceed in when a system is experiencing performance problems.
(這個檢視可以用來作為查詢瓶頸問題的Starting point.)

v$session_wait has a row for every session connected to the instance. It indicates if the session is:
Using Resource
Waiting for a Resource
Idle(waiting on one of the idle events);
不管會話是否在使用資源,都會有一行記錄。

##################################################################
2 Userful Columns for v$session_wait
##################################################################
1) SID: Session identifier for the session (可以與v$session結合,找到來自哪裡的會話正在等待某個事件)

2) Event: Event the session is currently waiting for, or the last event the session had to wait for.
(當前正在等待的事件,或最後一個等待的事件)

3) Wait_time: Time(in hundredths of a second) that the session waited for the event; if the WAIT_TIME is 0, then the session is currently waiting for the event.
(等待時間,
如果為0,表示正在等待
>0 Time waited in the last wait(in 10ms clock ticks) 等待時間,以10ms 為一個滴嗒。

-1 Time waited in the last wait was less than 10ms  小於10ms的等待時間

-2 Timing is not enabled (Timing沒開啟)



4) Seq#: Gets Incremented with every wait for the session.
等待序號,會話每等待一個事件,Seq#遞增

5) P1,P2,P3: Wait event specific details for the wait.
詳細描述等待事件


6) P1TEXT, P2TEXT, P3TEXT: Description of P1,P2,P3 for the given event



##################################################################
3 示例
##################################################################
1) Finding Current Waits on the System
查詢當前的等待事件

SELECT event,
sum(decode(wait_time,0,1,0)) "Curr",
sum(decode(wait_time,0,0,1)) "Prev",
count(*)"Total"
FROM v$session_wait
GROUP BY event
ORDER BY count(*);


EVENT                                                                  Curr       Prev      Total
---------------------------------------------------------------- ---------- ---------- ----------
pmon timer                                                                1          0          1
smon timer                                                                1          0          1
rdbms ipc message                                                         5          0          5
SQL*Net message from client                                              16          1         17



SELECT event,
sum(decode(wait_Time,0,0,DECODE(s.status,'ACTIVE',1,0))) "Prev",
sum(decode(wait_Time,0,1,DECODE(s.status,'ACTIVE',1,0))) "Curr",
count(*) "Tot"
FROM v$session s, v$session_wait w
WHERE s.sid = w.sid
GROUP BY event
ORDER BY count(*);




2.列出指定ID的等待事件
select * from v$session_wait where sid=XXX;



3.應用p1,p2,p3進行等待事件的分析

v$session_wait檢視的列代表的緩衝區忙等待事件如下:
P1—與等待相關的資料檔案的全部檔案數量。
P2—P1中的資料檔案的塊數量。
P3—描述等待產生原因的程式碼。
例:select p1 "File #", p2 "Block #", p3 "Reason Code"
  from v$session_wait
  where event = 'buffer busy waits';

如果以上查詢的結果顯示一個塊在忙等待,以下的查詢將顯示這一塊的名稱和型別:

select owner, segment_name, segment_type
 from dba_extents
 where file_id = &P1 and &P2 between block_id and block_id + blocks -1;

我們也可以查詢dba_data_files以確定等待的檔案的file_name,方法是使用v$session_wait中的P1。

從v$session_wait中查詢P3(原因編碼)的值可以知道session等待的原因。原因編碼的範圍從0到300,下列為部分編碼所代表的事項:
0 塊被讀入緩衝區。
100 我們想要NEW(建立)一個塊,但這一塊當前被另一session讀入。
110 我們想將當前塊設為共享,但這一塊被另一session讀入,所以我們必須等待read()結束。
120 我們想獲得當前的塊,但其他人已經將這一塊讀入緩衝區,所以我們只能等待他人的讀入結束。
130 塊被另一session讀入,而且沒有找到其它協調的塊,所以我們必須等待讀的結束。緩衝區死鎖後這種情況也有可能產生。所以必須讀入塊的CR。
200 我們想新建立一個block,但其他人在使用,所以我們只好等待他人使用結束。
210 Session想讀入SCUR或XCUR中的塊,如果塊交換或者session處於非連續的TX模式,所以等待可能需要很長的時間。
220 在緩衝區查詢一個塊的當前版本,但有人以不合法的模式使用這一塊,所以我們只能等待。
230 以CR/CRX方式獲得一個塊,但塊中的更改開始並且沒有結束。
231 CR/CRX掃描找到當前塊,但塊中的更改開始並且沒有結束。



 

##################################################################
4 v$session_event
##################################################################
This view summarizes wait events for every session. While v$session_wait shows the current waits for a session.
v$session_event provides summary of all the events has waited for since it started.

列上與v$system_event差不多。


##################################################################
5  問題
##################################################################
1) 對P1,P2,P3的理解仍不知道啥意思?不同的等待事件,不同的意思



































 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10248702/viewspace-669521/,如需轉載,請註明出處,否則將追究法律責任。

相關文章