Oracle v$session_wait

V$SESSION_WAIT View
The V$SESSION_WAIT view provides detailed information about the event or resource that each session is waiting for. This view contains only one row of information per session, active or inactive,

at any given time. Unlike the other views, this view displays session-level wait information in real time. Because of this, it may very well show different results each time you query the view.

V$SESSION_WAIT 视图记录了每个session等待事件或资源的详细信息,每个session在视图中只记录一条记录。包括 active和inactive两种状态,与其他动态性能视图不同的是,该视图中的信息是实时的,所以每次查询 的结果可能就不一样。

该视图的表结构如下:

  1. SQL> desc v$session_wait

  2. Name Type Nullable Default Comments

  3. --------------- ------------ -------- ------- --------

  4. SID NUMBER Y

  5. SEQ# NUMBER Y

  6. EVENT VARCHAR2(64) Y

  7. P1TEXT VARCHAR2(64) Y

  8. P1 NUMBER Y

  9. P1RAW RAW(4) Y

  10. P2TEXT VARCHAR2(64) Y

  11. P2 NUMBER Y

  12. P2RAW RAW(4) Y

  13. P3TEXT VARCHAR2(64) Y

  14. P3 NUMBER Y

  15. P3RAW RAW(4) Y

  16. WAIT_CLASS_ID NUMBER Y Starting Oracle10g

  17. WAIT_CLASS# NUMBER Y Starting Oracle10g

  18. WAIT_CLASS VARCHAR2(64) Y Starting Oracle10g

  19. WAIT_TIME NUMBER Y

  20. SECONDS_IN_WAIT NUMBER Y

  21. STATE VARCHAR2(19) Y

As you already know, the column SID shows the session identifier, and EVENT contains the name of the event. The columns P1, P2, and P3 contain specific information about the event and identify a

specific resource the session is waiting for. The interpretation of these values is event dependent. The columns P1RAW, P2RAW, and P3RAW contain the hexadecimal representation of the values

in P1, P2 and P3, respectively. To help you reference what these values pertain to, the columns P1TEXT, P2TEXT, and P3TEXT provide the description for columns P1, P2 and P3, respectively.

The column SEQ# is an internal sequence number for the event related to the session. It increments each time the session waits on the event. The WAIT_TIME column records the amount of time the

session has waited for. A negative value denotes unknown wait time, a value equal to zero means that the session is still waiting, and a value greater than zero is the actual wait time. 

WAIT_TIME 列记录了会话的等待时间,负值表示未知的等待时间,等待0表示正在等待,大于0表示实际等待的时间,

The column SECONDS_IN_WAIT shows wait time in seconds while the session is waiting on the event. The STATE column shows the current wait status. The trio ofSTATE, WAIT_TIME, and
SECONDS_IN_WAIT should be evaluated together, and the next section shows you how to do that. The WAIT_CLASS_ID, WAIT_CLASS#, and WAIT_CLASS columns are introduced in Oracle

Database 10g Release 1 to support the wait event classification feature.

应该将STATE, WAIT_TIME, and SECONDS_IN_WAIT三列的数据一起评估,接下来的章节会告诉如何去看这三列的值。

How to Use V$SESSION_WAIT View
A good time to query the V$SESSION_WAIT view is when you get a call about a slow running application and you want to investigate what the application is doing at that particular moment. Due
to its real-time nature, you have to query this view repeatedly, most likely in quick successions. You may see different wait events cycle through quickly, which means the application is actively
working, or you may see the application continue to wait on the same event, which means it could be idle or actively waiting on a particular resource such as a lock, a latch or, in case of a resumable
session (from Oracle9i Database), a disk space–related issue. Obviously, this view is useful only for current waits and does not provide a history of past wait events. However, that is changed in Oracle Database 10g Release 1. See the “V$SESSION_WAIT_HISTORY View” section for more information. As explained in the previous section, P1, P2, and P3 are attributes that describe the wait event they
are associated with. P1RAW, P2RAW, and P3RAW are the hexadecimal equivalents of P1, P2, and P3. You should familiarize yourself with the attributes of common wait events, but in case you
forget, you can get their descriptions from the P1TEXT, P2TEXT, and P3TEXT columns. For rootcause analysis, you must translate the attributes into meaningful information. For example, you can
obtain the object name that the db file sequential read and db file scattered read events are
referencing by translating their P1 and P2 values. Likewise, you can find out the name of the latch
that the session is waiting on by translating the P2 value. No doubt this can be a very tedious task if
you try to do it manually. By the time you successfully translate one event, many other events could
go by unnoticed. Oracle Database 10g Release 1 simplifies this task for latch and enqueue wait events. Common
latches have their own wait events, for example, latch: redo copy and latch: cache buffers chains.
All enqueues have their own wait events, for example, enq: TX - row lock contention and enq: ST - contention.
The STATE column has four possible values: WAITED UNKNOWN TIME, WAITED SHORT TIME, WAITING, and WAITED KNOWN TIME, and their meanings are as follows:

  • WAITED UNKNOWN TIME simply means that the TIMED_STATISTICS initialization parameter is set to FALSE and Oracle is unable to determine the wait time. In this case, the WAIT_TIME column shows –2.
  • WAITED SHORT TIME means the previous wait was less than one centisecond. In this case, the WAIT_TIME column shows –1.
  • WAITING means that the session is currently waiting and the WAIT_TIME column shows 0, but you can determine the time spent on this current wait from the SECONDS_IN_WAIT

Note In Oracle Database 10g Release 1 the V$SESSION_WAIT view is wholly incorporated into the V$SESSION view so that you can get pertinent information about the user session without having to join the two views.

批注:从10g Release 1开始,V$SESSION_WAIT中的信息完全包含在V$SESSION视图中了,不用再关联这两个视图进行查询了。

  • WAITED KNOWN TIME means Oracle is able to determine the duration of the last wait and the time is posted in theWAIT_TIME column.

STATE 列包括四个状态值,下面分别作说明:

WAITED UNKNOWN TIME:意味着初始化参数TIMED_STATISTICS=FALSE,这时Oracle不确定等待时间,这种时的WAIT_TIME列的值为-2

WAITED SHORT TIME       :意味着之前 的等待不超过1厘秒,这时的WAIT_TIME值为-1

WAITING                               :意味着当前session正处理等待状态,这时的WAIT_TIME值为0,但是通过SECONDS_IN_WAIT列的值可以知道已经等了多长时间。

WAITED KNOWN TIME      :意味着Oracle已经确定最后的持续时间的等待,这个值在WAIT_TIME列中。

上面的STAT列的不同值 ,阐明 了如何结合STATE, WAIT_TIME, and SECONDS_IN_WAIT这三列评估SESSION的等待情况。

When monitoring the V$SESSION_WAIT view, pay particular attention to the events with STATE=WAITING. This indicates the sessions are actively waiting on the event. The SECONDS_IN_WAIT column shows how long the sessions have been waiting. Also, bear in mind that you should not judge performance based on just one wait occasion. If you want to know how much time a session has waited on a particular wait event, you should consult theV$SESSION_EVENT view.

猜你喜欢

转载自blog.csdn.net/qq_34556414/article/details/82878271