V$SESSION_EVENT shows the wait statistics for each live session. Although
waits affect processes rather than sessions, they are recorded against sessions
because sessions can migrate between processes (as in Multi-Threaded Server
configurations). The cumulative session wait statistics have two main uses.
V$session_event为每个存在的session显示等待统计量。尽管进程比会话更受等待的影响,他们也被记录。因为会话能在进程直接迁移,累积的会话等待统计量有两种主要的用途。
First, if a particular user reports an episode of poor performance, then the wait
statistics for that session can be examined to diagnose that user's problem. The
APT script called session_times.sql (see Example 2.2) shows the waiting time
accumulated by the session for each type of event waited for, together with the
amount of CPU time consumed by that session. This makes it easy to see whether
the session has been working or waiting, and if it has been waiting, what it has
been waiting for.
第一,如果某个用户反映性能差,那么他的session的wait statistics能用来诊断这个用户的问题。Session_times.sql显示这个session各种等待的累积等待时间,和消耗的CPU时间。这样很容易看出这个session是在工作还是在等待,如果在等待,在等待什么。
Example 2.2. Sample Output from session_times.sql
SQL> @session_times
Enter SID: 29
EVENT
TIME_WAITED
---------------------------------------------------------------- ------
-----
SQL*Net message from client
2954196
CPU used by this session
1657275
db file sequential read
246759
write complete waits
139698
buffer busy waits
61832
log file sync
32601
enqueue
9576
log file switch completion
3530
SQL*Net message to client
2214
db file scattered read
1879
SQL*Net more data to client
952
SQL*Net more data from client
908
latch free
840
free buffer waits
100
buffer deadlock
57
row cache lock
1
SQL*Net break/reset to client
0
Second, if there has been extensive waiting for a particular type of resource, then
the session wait statistics can be used to determine which of the sessions that are
still connected have contributed to or been affected by the problem. The APT
script for this job is called resource_waiters.sql . It shows the breakdown by
session of the waiting time for the resource type in question. The total waiting
time for sessions that are no longer active is also shown. For example, if there
have been a large number of buffer busy waits, then looking at the session wait
statistics may reveal whether the problem has been widespread, or confined to
just a few sessions.
第二,如果一直特定的资源等待广泛,那么the session wait statistics能用来判断主要是哪个session造成的。Resource_waiters.sql可以完成这个工作。它显示等待这个资源类型的session的问题。非活动session的the total waiting time 也显示。举例来说,一个很大的buffer busy waits ,那么session的wait sttistice 可以说明这个问题是普遍存在还是个别现象。