Documente Academic
Documente Profesional
Documente Cultură
#.2
Redo
Row Cache SQL*Net
#.3
RBS
#.4
Data Files
Buffer Cache
Caches data blocks from disk that are heavily used
Shadow
#.5
Buffer Cache
Process
Disk
Copyright 2006 Kyle Hailey
Block in cache?
How do you know if a block is cached? Do you search all the blocks? Could be 1000s of blocks to search.
#.6
?
Shado w
Proces s
Copyright 2006 Kyle Hailey
#.7
Buffer Cache
Find a block by Take Data file # Block# and Hash Them
#.8
Hashing I
Simple has could be a Mod function
1
#.9
Hashing II
Empty Buckets 0
1 2 3
#.10
Hashing III
Data Block Hash Blocks file# block #s Result in a bucket# Put Block in bucket
0
1 2 3
#.11
Hashing IV
0
1 2 3
#.12
Hashing V
After a while the buckets become populated with blocks
0
1 2 3
#.13
To Find a Block
Hash bucket Buffer Headers Data Blocks
Shadow Process
1. 2. 3. 4.
Hash the block address Look for header Found, read block in cache Not Found Read block off disk
#.14
0
1 2 3
1 2 3 4
Note: multiple buckets are now protected by one latch Copyright 2006 Kyle Hailey
#.15
Well Balanced
Buffer Headers
Hash Buckets
4 5 6 7 8 9 1 0
#.16
Hash Buckets
Buffer Headers
2
#.17
s1 s1 s1 s1 s1
Hash Buckets
Sessions
#.18
Hash Buckets
#.19
Hot
root block of an index Select for update Using dual instead of x$dual
#.20
a free block in the buffer cache Read it off disk Add a header Read the block into the buffer cache
#.21
Process
#.22
Buffer Headers are also on a LRU linked List Copyright 2006 Kyle Hailey
#.23
Buffer Headers
LRU
Session Shadow
LRU = Least Recently Used MRU = Least Recently Used Copyright 2006 Kyle Hailey
#.24
to the LRU end of data blocks Look for first non-dirty block If search too many post DBWR to make free Free Buffer wait
#.25
Inefficient SQL
requesting
large # of blocks
#.26
Buffer Headers
LRU
Used Block gets put on Front Unused blocks get pushed off
#.27
Buffer Headers
LRU
One Latch protects the linked list during changes to the list
#.28
Buffer Headers
LRU
Mid-Point Insertion
#.29
LRU
Mid-Point Insertion
Oracle Tracks the touch count of blocks. As the block is pushed to the LRU end, if its touch count is 3 or more, its promoted to the MRU end
#.30
Buffer Headers
#.31
#.32
1
User1
2
User2 3
Copyright 2006 Kyle Hailey
#.33
Buffer Busy
14 kinds of blocks
Undo Header - more RBS segs data (index and table are different for bbw) segment header free lists freelist blocks free lists groups
#.34
Index Table
Segment
Header
If Pre 10
Read
#.35
Segment Header add free Lists (with Datablock) Free List add free lists groups
Copyright 2006 Kyle Hailey
#.36
look at v$waitstat
Class Time/Count
SQL> select
* from v$waitstat;
CLASS COUNT TIME ------------------ ---------- ---------data block 1 1 segment header 0 0 free list 0 0 undo header 0 0 undo block 0 0
Copyright 2006 Kyle Hailey
#.37
Class Waits Total Wait Time (s) Avg Time (ms) ---------------------- ----------- ------------------- ------------undo header 1,159 18 16 data block 132 2 12 file header block 45 0 2 segment header 4 0 10 undo block 1 0 0 ------------------------------------------------------------
#.38
Load : Example
4 Sessions running
Insert into toto values (null, a); Commit;
#.39
S1
S2
S3
S4
#.40
S1
S2
S3
S4
10g
SQL> select * from v$waitstat; CLASS COUNT TIME --------------------------- ---------1. data block 89640 13732 2. sort block 0 0 3. save undo block 0 0 4. segment header 1017 2558 5. save undo header 0 0 6. free list 0 0 7. extent map 0 0 NAME P1 8. 1st level bmb 204874 18896 9. 2nd level bmb 155 2 ----------------------10.3rd level bmb 0 0 11.bitmap blockbuffer busy waits 0 0 file# 12.bitmap index block 0 0 13.file header block 0 0 14.unused 0 0 15.system undo header 0 0 16.system undo block 0 0 17.undo header 219 122 18.undo block 0 0
Copyright 2006 Kyle Hailey
#.41
P2
P3
#.42
Happens because shadow wants to access blocks that are currently being written to disk by DBWR
#.43
#.44
: aleveate hot spots Data DML : add free lists Data Read: change app, tune I/O RBS : more RBS segs, use UNDO
Write Complete Waits : increase cache size Local Write Wait : truncates / reduce cache size
Copyright 2006 Kyle Hailey