前言:SGA的组件之一 Database Buffer Cache
Oracle Memory Architecture-Oracle 体系结构篇 2 http://blog.csdn.net/u010993297/article/details/9389403
1. Database Buffer Cache 数据库高效缓冲区
The database buffer cache, also called the buffer cache, is the memory area that stores copies of data blocks read from data files. Abuffer is a main memory address in which the buffer manager temporarily caches a currently or recently used data block. All users concurrently connected to a database instance share access to the buffer cache.
The buffer cache to achieve the following goals:
>>Optimize physical I/O
The database updates data blocks in the cache and stores metadata about the changes in the redo log buffer. After aCOMMIT
, the database writes the redo buffers to disk but does not immediately write data blocks to disk. Instead, database wirter (DBWn) performslazy writes in the background.
>>Keep frequently accessed blocks in the buffer cache and write infrequently accessed blocks to disk
When Database Smart Flash Cache (flash cache) is enabled, part of the buffer cache can reside in the flash cache. This buffer cache extension is stored on a flash disk device, which is a solid state storage device that uses flash memory. The database can improve performance by caching buffers in flash memory instead of reading from magnetic disk.
Database Smart Flash Cache is available only in Solaris and Oracle Enterprise Linux.
2. Database Buffer Cache states 缓冲区状态
A buffer can be in any of the following mutually exclusive states:
>> Unused 未使用状态
The buffer is available for use because it has never been used or is currently unused. This type of buffer is the easiest for the database to use.
>>Clean 干净状态
This buffer was used earlier and now contains a read-consistent version of a block as of a point in time. The block contains data but is "clean" so it does not need to be checkpointed. The database can pin the block and reuse it.
>>Dirty 脏状态
The buffer contain modified data that has not yet been written to disk. The database must checkpoint the block before reusing it.
Every buffer has an access mode: pinned orfree (unpinned).
A buffer is "pinned" in the cache so that it does not age out of memory while a user session accesses it.
Multiple sessions cannot modify a pinned buffer at the same time.
The database uses a sophisticated algorithm to make buffer access efficient.
Pointers to dirty and nondirty buffers exist on the same least recently used (LRU) list, which has a hot end and cold end.
A cold buffer is one that has not been recently used. Ahot buffer is frequently accessed and has been recently used.
3. Buffer Modes
When a client requests data, Oracle Database retrieves buffers from the database buffer cache in either of the following modes:
>>Current mode 当期模式
A current mode get, also called a db block get, is a retrieval of a block as it currently appears in the buffer cache.
For example, if an uncommitted transaction has updated two rows in a block, then a current mode get retrieves the block with these uncommitted rows.
The database uses db block gets most frequently during modification statements, which must update only the current version of the block.
>>Consistent mode 一致性模式
A consistent read get is a retrieval of a read-consistent version of a block.
This retrieval may use undo data.
For example, if an uncommitted transaction has updated two rows in a block,
and if a query in a separate session requests the block,
then the database uses undo data to create a read-consistent version of this block (called a consistent read clone)
that does not include the uncommitted updates.
Typically, a query retrieves blocks in consistent mode.
待续............