Database Writer Process (DBWn) (114)

tsinglee發表於2007-10-30

The database writer process (DBWn) writes the contents of buffers to datafiles. The
DBWn processes are responsible for writing modified (dirty) buffers in the database
buffer cache to disk. Although one database writer process (DBW0) is adequate for
most systems, you can configure additional processes (DBW1 through DBW9 and
DBWa through DBWj) to improve write performance if your system modifies data
heavily. These additional DBWn processes are not useful on uniprocessor systems.

When a buffer in the database buffer cache is modified, it is marked dirty. A cold
buffer is a buffer that has not been recently used according to the least recently used
(LRU) algorithm. The DBWn process writes cold, dirty buffers to disk so that user
processes are able to find cold, clean buffers that can be used to read new blocks into
the cache. As buffers are dirtied by user processes, the number of free buffers
diminishes. If the number of free buffers drops too low, user processes that must read
blocks from disk into the cache are not able to find free buffers. DBWn manages the
buffer cache so that user processes can always find free buffers.
By writing cold, dirty buffers to disk, DBWn improves the performance of finding free
buffers while keeping recently used buffers resident in memory. For example, blocks
that are part of frequently accessed small tables or indexes are kept in the cache so that
they do not need to be read in again from disk. The LRU algorithm keeps more
frequently accessed blocks in the buffer cache so that when a buffer is written to disk,
it is unlikely to contain data that will be useful soon.
The initialization parameter DB_WRITER_PROCESSES specifies the number of DBWn
processes. The maximum number of DBWn processes is 20. If it is not specified by the
user during startup, Oracle determines how to set DB_WRITER_PROCESSES based on
the number of CPUs and processor groups.
The DBWn process writes dirty buffers to disk under the following conditions:
■ When a server process cannot find a clean reusable buffer after scanning a
threshold number of buffers, it signals DBWn to write. DBWn writes dirty buffers
to disk asynchronously while performing other processing.
■ DBWn periodically writes buffers to advance the checkpoint, which is the position
in the redo thread (log) from which instance recovery begins. This log position is
determined by the oldest dirty buffer in the buffer cache.
In all cases, DBWn performs batched (multiblock) writes to improve efficiency. The
number of blocks written in a multiblock write varies by operating system.

資料庫寫程式
1. 將緩衝區中的內容(髒列表)寫入到資料檔案
2. DB_WRITER_PROCESSES引數指定DBWn程式的數目 , 最大數目為20 , 如果在啟動時使用者沒有指定 , Oracle
將根據cpu的數量和程式組來設定DB_WRITER_PROCESSES
3. 在以下情況 , 資料庫寫程式將髒緩衝區的資料寫入磁碟
a. 當伺服器程式掃描超過緩衝區的閥值還找不到clean reusable buffer
b. DBWn periodically writes buffers to advance the checkpoint

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10599713/viewspace-979560/,如需轉載,請註明出處,否則將追究法律責任。

相關文章