ITPub博客

首页 > 数据库 > 数据库开发技术 > Organization of the Database Buffer Cache (80)

Organization of the Database Buffer Cache (80)

原创 数据库开发技术 作者:tsinglee 时间:2007-10-23 15:38:14 0 删除 编辑

The buffers in the cache are organized in two lists: the write list and the least recently
used (LRU) list. The write list holds dirty buffers, which contain data that has been
modified but has not yet been written to disk. The LRU list holds free buffers, pinned
buffers, and dirty buffers that have not yet been moved to the write list. Free buffers
do not contain any useful data and are available for use. Pinned buffers are currently
being accessed.
When an Oracle process accesses a buffer, the process moves the buffer to the most
recently used (MRU) end of the LRU list. As more buffers are continually moved to the
MRU end of the LRU list, dirty buffers age toward the LRU end of the LRU list.
The first time an Oracle user process requires a particular piece of data, it searches for
the data in the database buffer cache. If the process finds the data already in the cache
(a cache hit), it can read the data directly from memory. If the process cannot find the
data in the cache (a cache miss), it must copy the data block from a datafile on disk
into a buffer in the cache before accessing the data. Accessing data through a cache hit
is faster than data access through a cache miss.
Before reading a data block into the cache, the process must first find a free buffer. The
process searches the LRU list, starting at the least recently used end of the list. The
process searches either until it finds a free buffer or until it has searched the threshold
limit of buffers.
If the user process finds a dirty buffer as it searches the LRU list, it moves that buffer
to the write list and continues to search. When the process finds a free buffer, it reads
the data block from disk into the buffer and moves the buffer to the MRU end of the
LRU list.
If an Oracle user process searches the threshold limit of buffers without finding a free
buffer, the process stops searching the LRU list and signals the DBW0 background
process to write some of the dirty buffers to disk.

Database Buffer Cache结构
write list :脏列表 , 也就是被更改但还没有写入磁盘的数据 .
the least recently used (LRU) list :free buffers(无有用数据 , 可供使用), pinned buffers(正被访问), 未转移到write list的dirty buffers。
当Oracle访问缓存区 ,将该buffer移动到MRU .
当用户进程请求一数据块 , Oracle首先在database buffer cache查找是否有该数据块,如果找到 , 则称为cache hit ,可以直接从内存中读取 ,
如果没有找到 ,则称为cache miss, 这时候需要从磁盘上的数据文件复制该数据块到cache buffer后 , 才能访问这些数据。
在读取数据块到cache之前 , 进程需要先从lru(从尾至头)查找一个free buffer, 要么找到 ,要么达到buffers阀值 .
如果找到一个dirty buffer , 把它移除到write list 并且继续查找 , 当找到free buffer后 ,进程将会从磁盘把数据块读入buffer ,
并且把buffer移到mru . 如果查找达到buffer的阀值还没有找到free buffer , 进程将停止查找并且发出指令使dbw0后台进程将dirty buffer
数据写入磁盘

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10599713/viewspace-978170/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    740
  • 访问量
    1897665