gc buffer busy等待事件

 这2天RAC生产库出现gc buffer busy 等待事件,出现的应用情况为出单缓慢。下面是官方对此的解释:

gc buffer busy
  This wait event, also known as global cache buffer busy prior to Oracle 10g, 
  specifies the time the remote instance locally spends accessing the requested data block. 
  This wait event is very similar to the buffer busy waits wait event in asingle-instance database and are often the result of:


1. Hot Blocks - 
multiple sessions may be requesting a block that is either not in buffer cache or is in an incompatible mode. 
Deleting some of the hot rows and re-inserting them back into the table may alleviate the problem.
 Most of the time the rows will be placed into a different block and reduce contention on the block. 
 The DBA may also need to adjust the pctfree and/or pctused parameters for the table to ensure the rows are placed into a different block.


2. Inefficient Queries ˆ 
as with the gc cr request wait event, 
the more blocks requested from the buffer cache the more likelihood of a session having to wait for other sessions.Tuning queries to access 
fewer blocks will often result in less contention for the same block.

--------------------------------------------------------------------
在10g 之前。这个等待事件叫做 global cache buffer busy,产生的原因和单实例的 buffer busy waits 类似
就是一个时间点节点a的实例向节点b请求block的等待。
产生原因:
  1:热块
  可能有多个session 请求这个数据块,有可能是数据块还没有读入 data buffer cache(某个session正在读入),或者session 间存在冲突的模式
一个会话在delete 热块的热行 并且重新插入的时候,有可能出现这个问题。
解决的办法是 修正 (扩大)pctfree 参数。来打散这个热块。
  2:低效的查询
  越多的数据块请求到buffer cache 中,那么越可能造成 别的会话等待。优化查询(sql),读入更少的lock。


解决过程

alter session set nls_timestamp_format='yyyy-mm-dd hh24:mi:ss.ff';

Session altered.

select SNAP_ID,INSTANCE_NUMBER,SAMPLE_TIME from dba_hist_active_sess_history where rownum=1;

   SNAP_ID INSTANCE_NUMBER SAMPLE_TIME
---------- --------------- ---------------------------------------------------------------------------
     21666               2 2012-12-03 11:00:12.153
	 
select SNAP_ID from dba_hist_active_sess_history where SAMPLE_TIME between to_timestamp('2012-12-04 10:00:00','yyyy-mm-dd hh24:mi:ss.ff') and 
to_timestamp('2012-12-04 12:00:00','yyyy-mm-dd hh24:mi:ss.ff');

21689

select wait_class_id, wait_class, count(*) cnt from dba_hist_active_sess_history  where snap_id=21689 group by wait_class_id, wait_class
order by 3;

WAIT_CLASS_ID WAIT_CLASS                                                              CNT
------------- ---------------------------------------------------------------- ----------
   2723168908 Idle                                                                      2
   3290255840 Configuration                                                             3
   2000153315 Network                                                                  13
   4108307767 System I/O                                                               28
   3386400367 Commit                                                                  130
   1893977003 Other                                                                   216
   3875070507 Concurrency                                                            1822
   1740759767 User I/O                                                               5473
                                                                                     8297
   4217450380 Application                                                           16657
   3871361733 Cluster                                                              114836

11 rows selected.


SELECT event_id, event, COUNT (*) cnt  
FROM dba_hist_active_sess_history  
WHERE snap_id=21689 AND wait_class_id = 3871361733  
GROUP BY event_id, event  
ORDER BY 3;


  EVENT_ID EVENT                                                                   CNT
---------- ---------------------------------------------------------------- ----------
1742950045 gc current retry                                                          1
3897775868 gc current multi block request                                            3
2701629120 gc current block busy                                                     3
 512320954 gc cr request                                                             4
1077045392 gc current block unknown                                                  5
 667696377 gc current grant congested                                                7
  75296820 gc remaster                                                              17
2705335821 gc cr block congested                                                    25
1520064534 gc cr block busy                                                         29
1445598276 gc cr disk read                                                          71
3794703642 gc cr grant congested                                                   124
3785617759 gc current block congested                                              136
2277737081 gc current grant busy                                                   356
2685450749 gc current grant 2-way                                                  365
 737661873 gc cr block 2-way                                                      1365
3201690383 gc cr grant 2-way                                                      6109
 111015833 gc current block 2-way                                                 7915
 661121159 gc cr multi block request                                             12166
1478861578 gc buffer busy                                                        86135


spool sql_id.txt
SELECT sql_id, COUNT (*) cnt  
FROM dba_hist_active_sess_history  
WHERE snap_id=21689 AND event_id IN (661121159, 1478861578)  
GROUP BY sql_id  
HAVING COUNT (*) > 1  
ORDER BY 2;
spool off
--参看sql_id.txt
[oracle@host103] ~/bin 1007>tail -10 sql_id.txt 
65b19gtx3pq95        521                                                                                                                              
3ym50bscr504n        533                                                                                                                              
0y8c91ys5nh3a        578                                                                                                                              
538ytbrzda34c        673                                                                                                                              
9xtp115t3zbqd       1190                                                                                                                              
2nh8vygjwqty9       1562                                                                                                                              
a17rkh5dsxwb7       2606    

set line 250
set long 1000
set pagesize 0
spool sql_gc.txt
SELECT sql_id,SQL_TEXT  FROM dba_hist_sqltext d  WHERE sql_id IN(
'a17rkh5dsxwb7',
'2nh8vygjwqty9',
'9xtp115t3zbqd',
'538ytbrzda34c',
'0y8c91ys5nh3a',
'3ym50bscr504n',
'65b19gtx3pq95');
spool off;




你可能感兴趣的:(Oracle)