mysql v$session_V$SESSION_WAIT分析 – 提供7*24专业数据库(Oracle,SQL Server,MySQL等)恢复和Oracle技术服务@Tel:+86 134296...

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值