WAIT EVENT: latch: cache buffers chains

关于CACHE BUFFERS CHAINS描述

CACHE BUFFERS CHAINS latch is acquired when searching
for data blocks cached
in the buffer cache.

Since the Buffer cache is implemented as a
sum of chains of blocks, each of those chains is protected

by a child of this latch when needs to be scanned. Contention
in this latch can be caused by very heavy

access to a single block. This can require the application to be reviewed.

产生CACHE BUFFERS CHAINS原因

The main cause of the cache buffers chains latch contention is usually a hot block issue.

This happens when multiple sessions repeatedly access one or
more blocks that are protected

by the same child cache buffers chains latch.

CACHE BUFFERS CHAINS 处理方法

1) Examine the application to see if the execution of certain DML and SELECT statements can be reorganized to eliminate contention on the object.

处理方法如下:

--通过报告确定latch: cache buffers chains 等待

Top 5 Timed Events                                      Avg    %Total

~~~~~~~~~~~~~~~~~~                                      wait   Call

Event                          Waits        Time (s)    (ms)   Time   Wait Class

------------------------------ ------------ ----------- ------ ------ ----------

latch: cache buffers chains          74,642      35,421    475    6.1 Concurrenc

CPU
time                                        
11,422           2.0

log
file sync                       
34,890       1,748     50    0.3 Commit

latch
free                           
2,279         774    340    0.1 Other

db
file parallel write               18,818         768     41    0.1 System I/O

-------------------------------------------------------------

--找出逻辑读高sql

SQL ordered by Gets         DB/Inst:  Snaps: 1-2

-> Resources reported
for PL/SQL
code includes the resources used by all SQL

statements called by the code.

-> Total Buffer Gets:   265,126,882

-> Captured SQL account
for   99.8% of Total

                            Gets                CPU      Elapsed

Buffer Gets    Executions   per Exec     %Total Time (s) Time (s)  SQL Id

-------------- ------------ ------------ ------ -------- --------- -------------

   256,763,367       19,052     13,477.0   96.8
######## ######### a9nchgksux6x2

Module: JDBC Thin Client

SELECT * FROM SALES ....

     1,974,516      987,056          2.0    0.7    80.31    110.94 ct6xwvwg3w0bv

SELECT COUNT(*) FROM ORDERS ....

--逻辑读大对象

Segments by Logical Reads          

-> Total Logical Reads:     265,126,882

-> Captured Segments account
for   98.5% of Total

           Tablespace                      Subobject  Obj.       Logical

Owner         Name    Object Name            Name     Type         Reads  %Total

---------- ---------- -------------------- ---------- ----- ------------ -------

DMSUSER    USERS      SALES                           TABLE  212,206,208   80.04

DMSUSER    USERS      SALES_PK                        INDEX   44,369,264   16.74

DMSUSER    USERS      SYS_C0012345                    INDEX    1,982,592     .75

DMSUSER    USERS      ORDERS_PK                       INDEX      842,304     .32

DMSUSER    USERS      INVOICES                        TABLE      147,488     .06

          -------------------------------------------------------------

处理思路:

1.Look
for SQL that accesses the blocks
in question and determine
if the repeated reads are necessary.

  This may be within a single session or across multiple sessions.

2.Check
for suboptimal SQL (this is the most common cause of the events) 

 look
at the execution plan for
the SQL being run and try to reduce the

 gets per executions
which will minimize the number of blocks being accessed

 and therefore reduce the chances of multiple sessions contending
for the same block.

Note:1342917.1 Troubleshooting ‘latch: cache buffers chains’ Wait Contention

2) Decrease the buffer cache -although this may only help in a small amount of cases.

3) DBWR throughput may have a factor in this as well.If using multiple DBWR’s then increase the number of DBWR’s.

4) Increase the PCTFREE for the table storage parameters via ALTER TABLE or rebuild. This will result in less rows per block.

找出热点对象

First determine
which latch
id(ADDR) are interesting by examining the number of

sleeps
for this latch. The higher the
sleep count, the
more interesting the

latch
id(ADDR) is:

SQL>
select CHILD#  "cCHILD"

     ,      ADDR   
"sADDR"

     ,      GETS   
"sGETS"

     ,      MISSES 
"sMISSES"

     ,      SLEEPS 
"sSLEEPS"

     from
v$latch_children

     where name =
‘cache buffers chains‘

     order by 5, 1, 2, 3;

Run the above query a few
times to to establish the
id(ADDR) that has the most

consistent amount of sleeps. Once the
id(ADDR) with the highest
sleep count is found

then
this latch address can be used to get more
details about the blocks

currently
in the buffer cache protected by this latch.

The query below should be run just after determining the ADDR with

the highest
sleep count.

SQL> column segment_name
format a35

     select
/*+ RULE */

       e.owner ||‘.‘|| e.segment_name  segment_name,

       e.extent_id  extent#,

       x.dbablk - e.block_id + 1  block#,

       x.tch,

       l.child#

     from

       sys.v$latch_children  l,

       sys.x$bh  x,

       sys.dba_extents  e

     where

       x.hladdr  =
‘&ADDR‘ and

       e.file_id = x.file# and

       x.hladdr = l.addr and

       x.dbablk between e.block_id and e.block_id + e.blocks -1

     order by x.tch desc ;

Example of the output :

SEGMENT_NAME                     EXTENT#      BLOCK#       TCH    CHILD#

-------------------------------- ------------ ------------ ------ ----------

SCOTT.EMP_PK                       5            474          17     7,668

SCOTT.EMP                          1            449           2     7,668

Depending on the TCH column (The number of
times the block is hit by a SQL

statement), you can identify a hot block. The higher the value of the TCH column,

the
more frequent the block is accessed by SQL statements.

5) Consider implementing reverse key indexes (if range scans aren’t commonly used against the segment)

时间: 2024-10-11 04:39:46

WAIT EVENT: latch: cache buffers chains的相关文章

【转载】latch: cache buffers chains

本文转自惜分飞的博客,博客原文地址:www.xifenfei.com/1109.html,支持原创,分享知识! 当一个数据块读入sga区,相应的buffer header会被放置到hash列表上,我们称其这hash chains,chain在中文的意为链条或串的意思,表达就是关连性.如果一个进程想访问或修改hash chain上的block,它首先要获得"cache buffers chains" latch. 原因一:低效率的SQL语句(主要体现在逻辑读过高) cache buffe

latch: cache buffers chains故障处理总结(转载)

一大早就接到开发商的电话,说数据库的CPU使用率为100%,应用相应迟缓.急匆匆的赶到现场发现进行了基本的检查后发现是latch: cache buffers chains 作祟,处理过程还算顺利,当时忘了记录log,这里总结下处理思路,以便下次查看. 故障分析思路 查看等待事件,判断故障起因 SQL>select * from (select sid,event,p1,p2,p3,p1text,WAIT_TIME,SECONDS_IN_WAIT from v$session_wait wher

latch: cache buffers chains故障处理总结

故障分析思路 查看等待事件,判断故障起因 SQL>select * from (select sid,event,p1,p2,p3,p1text,WAIT_TIME,SECONDS_IN_WAIT from v$session_wait where wait_class# <> 6 order by wait_time desc) where rownum <=10; 确认为latch: cache buffers chains引起的故障后,查看latch的命中率 SQL>S

latch:cache buffers chains的优化思路

数据块在buffer cache存放是以linked list方式存放的.当一个session想要访问/修改buffer cache的block,首先需要通过hash算法检查该block是否存在于buffer cache中,检查相同的SQL语句是否存在于library cache中也是通过hash算法实现的.要判断block是否存在于buffer cache中,就需要扫描linked list(此处都是串行的,不能并发),获取block的信息.而扫描linked list必须获得一个latch,

shared pool 和buffer pool 详解(之二, Cache Buffers LRU Chain、Cache Buffers LRU Chain闩锁竞争与解决)

[深入解析--eygle]学习笔记 1.1.2  Cache BuffersLRU Chain闩锁竞争与解决 当用户进程需要读数据到Buffer Cache时或Cache Buffer根据LRU算法进行管理等,就不可避免的要扫描LRU  List获取可用Buffer或更改Buffer状态,我们知道,Oracle的Buffer Cache是共享内存,可以为众多并发进程并发访问,所以在搜索的过程中必须获取Latch(Latch是Oracle的一种串行锁机制,用于保护共享内存结构),锁定内存结构,防止

cache buffer 相关的闩锁等待事件(cache buffers lru chain/cache buffers chain)

cache buffers lru chain原因高负荷的cache吞吐量,效率差的sql语句(全表扫描,或不正确的index range scans)dbwr写出速度太慢,前台进程花费很多时间持有latch查找free buffer. cache buffers lru chain保护buffer的链表在cache中,当增加,移除,移动一个buffer从list时,cblc latch必须被获取.在SMP(对称多处理)的系统上,oracle自动设置LRU latche数量是cpu个数的一半.在

linux top命令中的cache &amp; buffers

今天用top查看系统具体进程使用系统资源的情况时,对cache和buffer这两个概念不是很清楚,研究了一下: **cache是高速缓存,用于CPU和内存之间的缓冲: **buffer是I/O缓存,用于内存和硬盘的缓冲* [原文链接](http://blog.chinaunix.net/uid-24020646-id-2939696.html) 当你在linux下频繁存取文件后,物理内存会很快被用光,当程序结束后,内存不会被正常释放,而是一直作为caching.这个问题,貌似有不少人在问,不过都

cache buffers

buffers缓冲,可以型象的理解为漏斗.如果有大量的数据要写入磁盘,由于数据量很大,磁盘不能一下子接收,所以这个时候,就有了buffer这个漏斗,先把数据放入这个漏斗里面,然后让它慢慢的注入磁盘,这就是buffer. cache 是缓存.由于进程从磁盘读数据的时候会比较慢,而在内存的速度比较快,所以进程会把将要用到的数据先慢慢读入到缓存里,用的时候,直接从内存中读取,这样比起用时从磁盘中读数据,来的快很多.

浅谈Linux 内存中的Cache: buffers 与 cached

Linux 内存中的Cache,真的能被回收么? 您真的了解Linux的free命令么? 在Linux系统中,我们经常用free命令来查看系统内存的使用状态.在一个RHEL6的系统上,free命令的显示内容大概是这样一个状态: 这里的默认显示单位是kb,我的服务器是128G内存,所以数字显得比较大.这个命令几乎是每一个使用过Linux的人必会的命令,但越是这样的命令,似乎真正明白的人越少(我是说比例越少). 一般情况下,对此命令输出的理解可以分这几个层次: 不了解.这样的人的第一反应是:天啊,内