[Oracle]常见的等待事件(二)

2014-11-24 15:05:19 · 作者: · 浏览: 1
file#=8 block#=224 blocks=8 obj#=23315 tim=1356470039700179
WAIT #47878792599648: nam='db file scattered read' ela= 19 file#=8 block#=241 blocks=7 obj#=23315 tim=1356470039700589
…….
db file sequential read
当访问一个不在SGA的数据块时,就会产生该事件,一般在用索引访问时频繁发生。
在一个正常的OLTP系统中,该事件占的比例比较大是正常的,但是如果该事件的等待事件非常长,则表示当前有大量的索引读取操作,可以考虑是否全表扫描更快速呢?或者磁盘I/O太慢?
首先,创建索引:
SQL> create index i_t on t(object_id);
索引已创建。
接着以索引访问表中数据:
SQL> alter session set tracefile_identifier='jujay';
会话已更改。
SQL> alter session set events '10046 trace name context forever ,level 12' ;
会话已更改。
SQL> select object_name from t where object_id=1000; --以索引访问表中数据
SQL> alter session set events '10046 trace name context off' ;
会话已更改。
SQL> select * from v$diag_info where name='Default Trace File';
INST_ID NAME
---------- ----------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------
1 Default Trace File
c:\app\xianzhu\diag\rdbms\orcl\orcl\trace\orcl_ora_12136_jujay.trc
c:\app\xianzhu\diag\rdbms\orcl\orcl\trace>tkprof orcl_ora_12136_jujay.trc orcl_ora_12136_jujay.txt
TKPROF: Release 11.2.0.1.0 - Development on 星期三 12月 26 13:23:29 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
查看trace文件中的内容:
SQL ID: 0bjnptjy6ctk2
Plan Hash: 2928007915
select object_name
from
t where object_id=1000
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.01 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 8 0.03 0.68 34 76 0 64
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 12 0.04 0.68 34 76 0 64
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 92
Rows Row Source Operation
------- ---------------------------------------------------
32 TABLE ACCESS BY INDEX ROWID T (cr=38 pr=34 pw=0 time=0 us cost=35 size=960 card=32)
32 INDEX RANGE SCAN I_T (cr=6 pr=2 pw=0 time=837 us cost=3 size=0 card=32)(object id 75191)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 9 0.00 0.00
db file sequential read 34 0.10 0.67
SQL*Net message from client 9 19.22 36.71
********************************************************************************
如上所示,df file sequential read事件出现
buffer busy waits & cache buffer chain
和buffer相关的等待事件是因为热块,根据数据块类型,解决方法不同:
*表数据块:考虑将数据分布在更多的数据块上,减少数据块被多用户同时访问的频率。
*索引数据块:当一个表的主键用sequence生成键值时,索引最右边的叶子节点容易成为热块,可以考虑使用反向索引。
free buffer —— 等待空闲缓冲区
当把数据块从磁盘读入内存时,如果内存已无空闲空间,则会产生该等待事件,可能的原因有:
1)Data buffer太小,需增大Data buffer
2)内存中脏数据太多,需增加DBWR进程数
buffer busy —— 缓冲区忙等待
当用户频繁地读取或修改同样的数据块时,就会出现该等待事件,如果该等待事件