Instance Architecture   «Prev  Next»
Lesson 8 Database Writer (DBW0)
Objective Identify the purpose of the DBW0 process.

(DBW0) Database Writer

The Database Writer (DBW0) process has one purpose in life: to write modified data back to the datafiles.

Changed data in dirty buffers

Oracle holds the most recently read data from disk in a memory area known as the database buffer cache. Whenever any of that data is changed, the buffers with the changed data are marked as dirty.
The database writer will periodically check for these dirty buffers, and write them back to the datafiles. The following SlideShow illustrates this process:

1) When a database first starts, all the database buffers are empty
2) As queries are executed, the cache begins to fill up. Blocks are read from disk and placed in the buffers.
3) UPDATE, INSERT, and DELETE statements cause the data in some blocks to change.
4) The database writer periodically checks for modified blocks and writes them back to disk.
5) Modified blocks are written to disk, but also kept in memory in case they are needed again.
6) If database activity slows, the database writer will catch up.

Oracle Database Writer
An instance may have up to ten database writer processes.
If an Oracle user process searches the threshold limit of buffers without finding a free buffer, the process stops searching the LRU list[1] and signals the DBW0 background process to write some of the dirty buffers to disk.

The following facts hold for Oracle 12c

Consider Multiple Database Writer (DBWR) Processes or I/O Slaves

Configuring multiple database writer processes, or using I/O slaves, is useful when the transaction rates are high or when the buffer cache size is so large that a single DBWn process cannot keep up with the load.


The DB_WRITER_PROCESSES initialization parameter lets you configure multiple database writer processes (from DBW0 to DBW9 and from DBWa to DBWj). Configuring multiple DBWR processes distributes the work required to identify buffers to be written, and it also distributes the I/O load over these processes. Multiple db writer processes are highly recommended for systems with multiple CPUs (at least one db writer for every 8 CPUs) or multiple processor groups (at least as many db writers as processor groups). Based upon the number of CPUs and the number of processor groups, Oracle Database either selects an appropriate default setting for DB_WRITER_PROCESSES or adjusts a user-specified setting.


If it is not practical to use multiple DBWR processes, then Oracle Database provides a facility whereby the I/O load can be distributed over multiple slave processes. The DBWR process is the only process that scans the buffer cache LRU list for blocks to be written out. However, the I/O for those blocks is performed by the I/O slaves. The number of I/O slaves is determined by the parameter DBWR_IO_SLAVES.
DBWR_IO_SLAVES is intended for scenarios where you cannot use multiple DB_WRITER_PROCESSES (for example, where you have a single CPU). I/O slaves are also useful when asynchronous I/O is not available, because the multiple I/O slaves simulate nonblocking, asynchronous requests by freeing DBWR to continue identifying blocks in the cache to be written. Asynchronous I/O at the operating system level, if you have it, is generally preferred. DBWR I/O slaves are allocated immediately following database open when the first I/O request is made. The DBWR continues to perform all of the DBWR-related work, apart from performing I/O. I/O slaves simply perform the I/O on behalf of DBWR. The writing of the batch is parallelized between the I/O slaves.

LRU Algorithm and Full Table Scans

[1] When the user process is performing a full table scan, it reads the blocks of the table into buffers and puts them on the LRU end (instead of the MRU end) of the LRU list. This is because a fully scanned table usually is needed only briefly, so the blocks should be moved out quickly to leave more frequently used blocks in the cache. You can control this default behavior of blocks involved in table scans on a table-by-table basis. To specify that blocks of the table are to be placed at the MRU end of the list during a full table scan, use the CACHE clause when creating or altering a table or cluster. You can specify this behavior for small lookup tables or large static historical tables to avoid I/O on subsequent accesses of the table.