Management mechanism of Oracle Buffer cache

Source: Internet
Author: User
Tags empty hash header

1, LRU linked list structure overview

In the front, we already know how Oracle searches the hash chain for the corresponding buffer header of the data block, and we know that if the desired buffer header is not found on the hash chain, Oracle will issue a i/ o Call, get the block of data from the data file on the disk and copy the contents of the block into a memory block in the buffer cache. This time, if the buffer cache is empty, relatively good to do, directly to take an empty memory block to use it. But if the buffer cache memory blocks are all used, there is no empty memory block, how to do? Which memory data block should I reuse? Of course, we can compare the memory data block to the contents of the data block corresponding to the data file, if consistent, the data block can be taken, the contents emptied, and the contents of the current block are copied into; if not, the data block is modified in memory, but not yet written to the data file. So the data block cannot be overwritten by other content, skip it, and then look for the next. There is no doubt that this approach is inefficient. In order to efficiently manage the memory block in buffer cache, Oracle introduced the LRU linked list structure.

In buffer cache, the most familiar linked list may be the LRU linked list. The LRU linked list can also be seen on the graph that describes the buffer cache structure earlier. Before introducing LRU, we will explain several concepts first.

Dirty data block (dirty buffer): The contents of the memory block in the buffer cache are modified, resulting in inconsistencies with the contents of the data block in the data file.

Free buffer: The memory data block in buffer cache is empty.

Clean buffer: The content of the buffer is consistent with the data file.

Pinned block of data (PIN buffer): The memory data block that is currently being updated.

Database write Process (DBWR): This is a very low-level database daemon. Since it is a background process, it means that the process cannot be invoked by the user. Some of the events built up by Oracle start the process as needed to write dirty blocks to data files on disk.

For free blocks and clean blocks of data, we are generally referred to as the available blocks of data because the content can be overwritten with the new data content. Data blocks of other states, such as dirty blocks, cannot be overwritten with new content.

LRU represents the least recently Used, which refers to the least recently used buffer header list. The buffer headers concatenated in the LRU list point to the available data blocks. The buffer is hung on the LRU linked list in the order of use, the buffer that is used first hangs in the back of the LRU list, and the buffer that is used is hung in front of the LRU list. If the buffer is modified by a DML statement, the buffer is taken off the LRU list. In other words, the buffer headers on the LRU list are the available blocks of data to which the buffer header points.

When the server process cannot find the empty buffer to hold the new data request, it needs to use the buffer that has already stored the data, that is, the content of the new data block overwrites the buffer used. When looking for which buffer to overwrite, Oracle scans the tail on the LRU list, and if the buffer being scanned is in use, skip the buffer and continue looking until it is found. If a certain amount of buffer is scanned, no available buffer is found, then the dirty block is too much, so trigger the DBWN process, the dirty block flushed to the data file, after the refresh, the contents of the buffer and data file in the same, so these dirty pieces into a clean buffer, You can also use it to cover the content. These clean buffer will be hung on the tail of the LRU linked list for use by the process.

When a process scans the available blocks on a LRU list, it is protected by the cache buffers LRU chain latch

2. DBWN Process

We already know that the DBWN process is responsible for writing dirty blocks to disk. It is a very important process, and with the increasing memory, a DBWN process may not be enough. So from Oracle 8i, we can configure multiple DBWN processes for the system. Initialization parameter Db_writer_processe determines how many dbwn processes are started. Each DBWN process assigns a cache buffers LRU chain latch.

Dbwn as a background process that triggers only when certain conditions are met. These conditions include:

When the process is scanned in the LRU list to find the buffer header that can be overwritten, the DBWN process is triggered if the number of buffer headers already scanned reaches a certain limit;

If the total number of dirty blocks exceeds a certain limit, the DBWN process will also be triggered;

Triggers dbwn when checkpoints occur, including incremental checkpoints (incremental checkpoint) and full checkpoints (complete checkpoint);

Start Dbwn once every three seconds;

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.