首页 > 数据库 > Oracle > oracle的等待事件
select event,
sum(decode(wait_Time, 0, 0, 1)) "Prev",
sum(decode(wait_Time, 0, 1, 0)) "Curr",
count(*) "Tot"
from v$session_Wait
group by event
order by 4;
Oracle的等待事件是衡量oracle运行状况的重要依据及指标.
等待事件的概念是在Oracle7.0.1.2中引入的,大致有100个等待事件。在Oracle 8.0中这个数目增加到了大约150个,在Oracle8i中大约有200个事件,在Oracle9i中大约有360个等待事件。
主要有两种类别的等待事件,即空闲(idle)等待事件和非空闲(non-idle)等待事件。
空闲等待事件是指Oracle正等待某种工作,比如用sqlplus登录之后,但没有进一步发出任何命令,此时该session就处于SQL*Net message from/to client等待事件状态,等待用户发出命令,任何的在诊断和优化数据库的时候,我们不用过多注意这部分事件。非空闲等待事件专门针对Oracle的活动,指数据库任务或应用运行过程中发生的等待,这些等待事件是我们在调整数据库的时候应该关注与研究的。
每一个等待事件都属于某一类, 下面给出了每一类等待事件的描述.
管理类: administrative
类等待事件是由于DBA的管理命令引起的,这些命令要求用户处于等待状态,比如,重建索引。
应用程序类:
此类等待事件是由于用户应用程序的代码引起的(比如:锁等待).
群集类:Cluster
此类等待事件和真正应用群集RAC的资源有关。(比如:gc cr block busy等待事件).
此类等待事件只包含一种等待事件--在执行了一个commit命令后,等待一个重做日志写确认(也就是log file sync).
此类等待事件是由内部数据库资源引起的,比如闩锁。
此类等待事件是由数据库或实例的不当配置造成的,比如,重做日志文件尺寸太小,共享池的大小等。
此类等待事件意味着会话不活跃,等待工作。比如,sql * net messages from client。
和网络环境相关的一些等待事件,比如sql* net more data to dblink。
此类等待事件通常比较少见。
Resource Manager related waits (for example, 'resmgr: become active')
此类等待事件通过是由后台进程的I/O操作引起的,比如DBWR等待,db file paralle write。
此类等待事件通常是由用户I/O操作引起的,比如db file sequential read。
1, db file scattered read (DB文件分散读取)
这种情况通常与全表扫描相关. 当数据库进行全表扫描时, 基于性能的考虑, 数据会分散(scattered)读入buffer cache. 如果这个等待事件比较显著, 可能考虑查看对应的表有没有创建合适的索引.
然而这个等待事件并不一定就意味着性能低下, 在某些条件下oracle会主动使用全表扫描来替换索引扫描以提高性能, 这和访问的数据量有关, 在CBO下oracle会进行更为智能的选择, RBO下oracle更倾向于使用索引.
因为全表扫描到内存的数据块被置于LRU链表的冷端, 所以这些数据块将可能在较短时间内被置换出物理内存, 为了避免反复物理IO, 对频繁访问的较小的数据表,可以选择把他们cache到内存中.
当这个等待时间比较显著时, 可以结合v$session_longops动态性能视图来进行诊断, 该视图中记录了长时间(运行时间超过6秒)运行的事务, 可能很多是全表扫描操作.
|
Column |
Datatype |
Description |
|
SID |
NUMBER |
Session identifier |
|
SERIAL# |
NUMBER |
Session serial number |
|
OPNAME |
VARCHAR2(64) |
Brief description of the operation |
|
TARGET |
VARCHAR2(64) |
The object on which the operation is carried out |
|
TARGET_DESC |
VARCHAR2(32) |
Description of the target |
|
SOFAR |
NUMBER |
The units of work done so far |
|
TOTALWORK |
NUMBER |
The total units of work |
|
UNITS |
VARCHAR2(32) |
The units of measurement |
|
START_TIME |
DATE |
The starting time of operation |
|
LAST_UPDATE_TIME |
DATE |
Time when statistics last updated |
|
TIME_REMAINING |
NUMBER |
Estimate (in seconds) of time remaining for the operation to complete |
|
ELAPSED_SECONDS |
NUMBER |
The number of elapsed seconds from the start of operations |
|
CONTEXT |
NUMBER |
Context |
|
MESSAGE |
VARCHAR2(512) |
Statistics summary message |
|
USERNAME |
VARCHAR2(30) |
User ID of the user performing the operation |
|
SQL_ADDRESS |
RAW(4) |
Used with the value of the SQL_HASH_VALUE column to identify the SQL statement associated with the operation |
|
SQL_HASH_VALUE |
NUMER |
Used with the value of the SQL_ADDRESS column to identify the SQL statement associated with the operation |
|
QCSID |
NUMBER |
Session identifier of the parallel coordinator |
2, db file sequential read(DB 文件顺序读取)
这一事件通常显示与单个数据块相关的读取操作, 比如对索引块的读取. 如果这个等待事件比较显著, 可能表示在多表连接中, 表的链接顺序存在问题, 可能没有正确的使用驱动表; 或者可能说明不加选择地进行索引.
3, free buffer (释放缓冲区)
这个等待事件表明系统正在等待内存中的可用空间,这说明当前Buffer 中已经没有Free 的内存空间。Free Buffer 等待可能说明DBWR 的写出速度不够,或者磁盘存在严重的竞争,可以需要考虑增加检查点、使用更多的DBWR 进程,或者增加物理磁盘的数量,分散负载,平衡IO。
4, buffer busy(缓冲区忙)
该等待事件表示正在等待一个以unshareable方式使用的缓冲区,或者表示当前正在被读入buffer cache。一般来说Buffer Busy Wait不应大于1%。检查缓冲等待统计部分(或V$WAITSTAT),看一下等待是否位于段头(Segment Header)。如果是,可以考虑增加自由列表(freelist,对于Oracle8i DMT)或者增加freelist groups(在很多时候这个调整是立竿见影的,在8.1.6之前,这个freelists参数不能动态修改;在8.1.6及以后版本,动态修改 feelists需要设置COMPATIBLE至少为8.1.6).
This view lists block contention statistics. This table is only updated when timed statistics are enabled.
|
Column |
Datatype |
Description |
|
CLASS |
VARCHAR2(18) |
Class of the block |
|
COUNT |
NUMBER |
Number of waits by this OPERATION for this CLASS of block |
|
TIME |
NUMBER |
Sum of all wait times for all the waits by this OPERATION for this CLASS of block |
select * from V$WAITSTAT
|
CLASS |
COUNT |
TIME |
|
data block |
318671 |
91287 |
|
undo header |
50352 |
1172 |
|
undo block |
28 |
1 |
|
segment header |
10 |
5 |
|
file header block |
8 |
1 |
|
1st level bmb |
3 |
0 |
|
bitmap index block |
0 |
0 |
|
system undo block |
0 |
0 |
|
system undo header |
0 |
0 |
|
unused |
0 |
0 |
|
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23861776/viewspace-1034633/ ,如需转载,请注明出处,否则将追究法律责任。
请登录后发表评论
登录
全部评论
|