All technological notes.
database buffer cache / buffer cache
buffer
Purpose
redo log buffer -> write to online redo log -> DBW lazy write to data file. 不是马上写入,而是先缓存, 再由 DBW 写入.A buffer can be in any of the following mutually exclusive states: 以下状态之一, 不能同时.
Unused
Clean
Dirty
access mode:
access mode: pinned or free (unpinned).Buffer Modes
current mode or consistent mode.Current mode
current mode get / db block get:
Consistent mode
consistent read get
buffer I/O / logical I/O
When a requested buffer is not found in memory,
physical I/O to copy the buffer from either the flash cache or disk into memory.logical I/O to read the cached buffer.Buffer Replacement Algorithms
LRU-based, block-level replacement algorithm
uses a least recently used (LRU) list that contains pointers to dirty and non-dirty buffers.
LRU list
cold buffer
hot buffer
LRU
LRUs.Temperature-based, object-level replacement algorithm
automatic big table caching feature enables table scans to use a different algorithm in the following scenarios:DB_BIG_TABLE_CACHE_PERCENT_TARGET = nonzero value, and PARALLEL_DEGREE_POLICY = auto or adaptive.DB_BIG_TABLE_CACHE_PERCENT_TARGET = nonzero value,DB_BIG_TABLE_CACHE_PERCENT_TARGET initialization parameter sets the percentage of the buffer cache that uses this algorithm.database writer (DBW) process periodically writes cold, dirty buffers to disk.
DBW writes buffers to disk when:
When the number of unused buffers is low, the database must remove buffers from the buffer cache.
The algorithm depends on whether the flash cache is enabled:
Flash cache disabled
Flash cache enabled
flash cache, enabling reuse of its in-memory buffer.When a client process requests a buffer, the server process searches the buffer cache for the buffer.
cache hit
cache miss
Buffer Search order:
logical read of this buffer.optimized physical read of the buffer body from the flash cache into the in-memory cache.cache miss), then the server process performs the following steps:
logical read of the buffer that was read into memory
Performance:
cache hit is faster than through a cache miss.The buffer cache hit ratio: -** how often** the database found a requested block in the buffer cache without needing to read it from disk.
physical reads can be performed from
data file
Reads from a data file are followed by logical I/Os.temp file.
temporary table and read it back later.logical I/O.touch count
The database does not physically move blocks in memory.
The three-second rule prevents a burst of pins on a buffer counting as many touches.
touch count is high, then the buffer** moves to the hot end**.
touch count is low, then the buffer ages out of the cache.buffer pool
The buffer cache is divided into one or more buffer pools, which manage blocks in mostly the same way.
DBA can manually configure separate buffer pools that either keep data in the buffer cache or make the buffers available for new data immediately after using the data blocks.
buffer pool to control how blocks age out of the cache.possible buffer pools
Default pool
The optional configuration of the other pools has no effect on the default pool.不受其他池影响
big table cache
default pool that uses a temperature-based, object-level replacement algorithm. 参见算法部分.Keep pool
Recycle pool

multiple pools are used.
- The cache contains
default,keep, andrecyclepools.- The default block size is 8 KB.
- The cache contains separate pools for tablespaces that use the nonstandard block sizes of
2KB,4KB, and16KB.