Tuning 04 Sizing the Buffer Cache

image

image

image

image

Buffer Cache 特性

The buffer cache holds copies of the data blocks from the data files. Because the buffer cache is a part of the SGA, these blocks can be shared by all users. The server processes read data from the data files into buffer cache.(是server process 将数据从硬盘读取到内存的) To improve performance, the server process sometimes reads multiple blocks in a single read. The DBWn process writes data from the buffer cache into the data files. To improve performance, DBWn writes multiple blocks in a single write.

DB_CACHE_SIZE: specifies the size of default buffer pool in bytes.

DBA_KEEP_CACHE_SIZE: specifies the size of keep buffer pool in bytes.

DBA_RECYCLE_CACHE_SIZE: specifies the size of recycle buffer pool in bytes.

The blocks in the buffer cache are managed using two lists:

- The least recently used(LRU) list is used to keep the most recently accessed blocks in memory. The blocks on the list are organized from the most recently used(MRU) to the recently used. (最后最多被使用)

- The dirty list points to blocks in the buffer cache that have been modified but not written to disk.

Blocks in the buffer cache can be in one or three states:

- Free buffers are blocks that have the same image on disk and in memory. These blocks are availiable for reuse.

- Dirty blocks are blocks with a different image in memory than the image on disk. These blocks must be written to disk before they can be reused.

- Pinned buffers are memory blocks that are currently being accessed.

imageimage

When a server needs a block, it follows these steps to read the block:

1. Firstm the server checks wether the required block is available in the buffer cache using a hash function. If the block is found, it is moved to another point in LRU list away from the LRU end. This is a logical read, because no actual I/O took place. If the block is not found in the buffer cache, the server process has to read the block from the data file.

2. Before reading from the data file, the server process searches the LRU list for a free block.

3. While searching the LRU list, the server process moves dirty blocks to the dirty list.

4. If the dirty list exceeds its size threshold, the server signals DBWn to flush dirty blocks from the data buffer cache. If the server cannot find a free block within a search threshold, it signals DBWn to flush.

5. After a free block is found, the server reads the block from the data file into the free block in the database buffer cache. Oracle server process moves the block away from the LRU end of the LRU list.

6. If the block is not consistent, the server rebuilds an earlier version of the block from the current block and rollback segments.

7. Dirty List Exceeds its Size Threshold: A server process finds that the dirty list has exceeded its size threshold, so it signals DBWn to flush. DBWn writes out the blocks on the dirty list.

8. Search Threshold Exceeded: A server process that cannot find a free block on the LRU list within the search threshold signals DBWn to flush dirty blocks. DBWn writes out dirty blocks directly from the LRU list.

image

image

可见, buffer cache 还是要提高命中率的问题, 即 让 server process 想找的block恰好在memory中, 直接进行操作.

To improve the cache hit ratio, the DBA can:

  • Increase the size of buffer cache
  • Use multiple buffer pools to separate blocks by access characteristics
  • Configure the tables to be cached in memory
  • Configure to bypass the buffer cache for sorting and parallel reads if possible.

另外一点可以看出, 监控系统的 I/O 操作也是很重要的

image

image

image

image

image

image

image

image

image

image

image

image

转载于:https://www.cnblogs.com/moveofgod/p/3629975.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值