How are dirty buffers managed?
In the Oracle ecosystem, a "Dirty Buffer" is simply a data block in the memory (SGA) that has been modified by a user but hasn't been written back to the physical disk yet.
Managing these buffers is a delicate balancing act. If Oracle writes them to disk too often, the database slows down due to heavy I/O. If it waits too long, a crash recovery will take hours. Here is how Oracle manages this "dirty work" behind the scenes.
When you update a row, Oracle doesn't touch the disk. Instead:
It finds the data block in the Buffer Cache.
It changes the data in RAM.
It marks that block as "Dirty."
It moves the block to a special internal list called the Write Queue (or Checkpoint Queue).
The block stays "dirty" in memory until a specific process decides it’s time to sync it with the physical data files.
The Database Writer (DBWn) is the process responsible for cleaning these buffers.
By staying lazy, DBWn allows multiple users to update the same block in memory many times, but it only performs one physical write to the disk eventually. This saves massive amounts of system resources.
DBWn doesn't just wake up at random. It manages dirty buffers based on these specific triggers:
If the Buffer Cache fills up with so many dirty buffers that there is no "clean" space left for new data being read from the disk, DBWn is forced to write some dirty blocks to make room.
When a Checkpoint occurs (like during a Log Switch), Oracle demands that all dirty buffers up to a certain point in time be written to disk.
To prevent a massive backlog of work, DBWn performs small, incremental writes every three seconds to keep the write queue manageable.
Oracle has a strict rule: LGWR must finish before DBWn can start.
Before a dirty buffer can be written to a data file, the corresponding Redo Log entry (the record of the change) must already be safely on the disk. This ensures that if the system crashes while DBWn is halfway through writing, the database can still be recovered.
| Component | Responsibility |
| Buffer Cache | Holds the dirty blocks in RAM. |
| Write Queue | The "to-do list" of blocks waiting to be written. |
| DBWn | The process that physically moves dirty blocks to disk. |
| LRU Algorithm | Ensures frequently used blocks stay in memory while "cold" dirty blocks are written first. |
If your dirty buffers aren't being managed fast enough, you will see a wait event called free buffer waits. This means your users are literally stuck waiting for DBWn to finish cleaning up the "mess" in memory before they can read any more data.
In high-performance 19c systems, you can increase the number of writers (e.g., DB_WRITER_PROCESSES = 4) to help clear the dirty buffers faster.