Beruflich Dokumente
Kultur Dokumente
How To Identify a Hot Block Within The Database Buffer Cache. [ID 163424.1]
#####
Applies to:
Oracle Server - Enterprise Edition - Version: 8.0.6.0 to 11.2.0.3 - Release: 8.0
.6 to 11.2
Information in this document applies to any platform.
Goal
How to identify blocks which cause latch contention on the 'cache buffers chains
' latch.
How to identify a hot block within the database buffer cache.
Solution
Possible hot blocks in the buffer cache normally can be identified by a high or
rapid increasing wait count on the CACHE BUFFERS CHAINS latch.
This 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 thos
e
chains is protected by a child of this latch when needs to be scanned. Contentio
n
in this latch can be caused by very heavy access to a single block. This can
require the application to be reviewed.
To solve a hot block, the application may need to be reviewed because the conten
tion may be caused by inefficient SQL that repeatedly accesses the same buffers
unnecessarily.
See:
Note:1342917.1 Troubleshooting 'latch: cache buffers chains' Wait Contention
By examining the waits on this latch, information about the segment and the
specific block can be obtained using the following queries.
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 f
ound
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.
In order to reduce contention for this object the following mechanisms can be pu
t in place:
1) Examine the application to see if the execution of certain DML and SELECT sta
tements can be reorganized to eliminate contention on the object. See:
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 c
ases.
3) DBWR throughput may have a factor in this as well.
If using multiple DBWR's then increase the number of DBWR's. See:
bh_lc,
dba_objects o
where bh_lc.obj = o.data_object_id(+)
order by 1,2 desc;
The output is something like following:
HLADDR TCH OWNER OBJECT_NAME OBJECT_TYP CHILD# GETS MISSES IMMEDIATE_GETS IMMEDI
ATE_MISSES SPIN_GETS SLEEPS
---------------- ----- -------------------- --------------------------------------- ---------- ------- ---------------- ---------------- ---------------- --------------- ---------------- ---------------0000000621ED8B00 127 SABXFER PCBDEMPRELEVEMENT TABLE 80750 703326 1649 8007 0 16
42 7
0000000621ED8B00 127 80750 703326 1649 8007 0 1642 7
0000000621ED8B00 74 SABXFER V_HIERARCHIEENTREPRISE_B TABLE 80750 703326 1649 800
7 0 1642 7
0000000621ED8B00 1 SABXFER SACNTPR_PK INDEX 80750 703326 1649 8007 0 1642 7
0000000621ED8B00 1 SABXFER SAENCR2_1 TABLE 80750 703326 1649 8007 0 1642 7
0000000621ED8B00 1 80750 703326 1649 8007 0 1642 7
0000000621ED8B00 0 80750 703326 1649 8007 0 1642 7
7 rows selected.