V$SESSION_WAIT分析

联系:手机/微信(+86 17813235971) QQ(107644445)QQ咨询惜分飞

标题:V$SESSION_WAIT分析

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

V$SESSION_WAIT displays the current or last wait for each session.

1、SID
Session identifier; maps to V$SESSION.SID

2、EVENT
session当前等待的事件,或者最后一次等待事件

3、WAIT_TIME
If the session is currently waiting, then the value is 0. If the session is not in a wait, then the value is as follows:
Value>0 – Value is the duration of the last wait in hundredths of a second
Value=-1 – Duration of the last wait was less than a hundredth of a second
Value=-2 – Parameter TIMED_STATISTICS was set to false

4、SEQ#
session等待事件将触发其值自增长

5、P1, P2, P3
等待事件中等待的详细资料

6、P1TEXT, P2TEXT, P3TEXT
解释说明p1,p2,p3事件

7、State
Wait state:
WAITING – Session is currently waiting
WAITED UNKNOWN TIME – Duration of the last wait is unknown; this is the value when the parameter TIMED_STATISTICS is set to false
WAITED SHORT TIME – Last wait was less than a hundredth of a second
WAITED KNOWN TIME – Duration of the last wait is specified in the WAIT_TIME column

8、SECONDS_IN_WAIT
If WAIT_TIME = 0, then SECONDS_IN_WAIT is the seconds spent in the current wait condition.
If WAIT_TIME > 0, then SECONDS_IN_WAIT is the seconds since the start of the last wait, and SECONDS_IN_WAIT – WAIT_TIME / 100 is the active seconds since the last wait ended.

9、Wait_time和Second_in_wait字段值与state相关
如果state值为Waiting,那么wait_time值无用。Second_in_wait值是实际的等待时间(单位:秒)。
如果state值为Wait unknow time,那么wait_time值和Second_in_wait值都无用。
如果state值为Wait short time,那么wait_time值和Second_in_wait值都无用。
如果state值为Waiting known time,那么wait_time值就是实际等待时间(单位:秒),Second_in_wait值无用。

10、应用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扫描找到当前块,但块中的更改开始并且没有结束

此条目发表在 Oracle性能优化 分类目录。将固定链接加入收藏夹。

评论功能已关闭。