oracle四个视图的特性,Oracle动态性能视图学习笔记(10)_v$session_wait

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/,如需转载,请注明出处,否则将追究法律责任。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值