Explain the function of DBWR, LGWR, SMON, PMON processes.
If the Oracle Instance is a high-functioning engine, the Background Processes are the mechanical parts that keep it from overheating, seizing up, or losing data.
While there are dozens of background processes in a modern Oracle database, four of them—DBWn, LGWR, SMON, and PMON—are the "Big Four." Without them, the database simply cannot function.
The Janitor
The Database Writer’s job is to take modified data (called "dirty buffers") from the memory (SGA) and write them onto the physical Data Files on the disk.
Why it exists: Writing to disk is slow. To keep the database fast, Oracle makes changes in memory first. DBWn eventually syncs those changes to the disk.
The "n" in DBWn: Large databases can have multiple writers (DBW0, DBW1, etc.) to handle heavy workloads.
Efficiency: It doesn't write every time you hit "Save." It writes in batches to optimize performance.
The Court Reporter
LGWR is arguably the most critical process for data integrity. It records every single change made to the database into the Redo Log Files.
The Golden Rule: Oracle follows a "Write-Ahead Logging" protocol. This means LGWR writes the record of the change to the disk before the actual data is updated in the data files.
Speed: Unlike the DBWn, which is lazy and waits for a batch, LGWR is fast. It writes the moment you COMMIT a transaction.
Safety: If the power goes out, Oracle uses the logs written by LGWR to "replay" the lost changes.
The Recovery Expert
SMON is the "housekeeping" process that keeps the system healthy. Its most famous role happens during a reboot after a crash.
Instance Recovery: If the database crashed unexpectedly, SMON wakes up during the next startup, checks the Redo Logs, and makes sure the data files are consistent.
Space Management: It cleans up "temporary segments" that are no longer needed (like the leftovers from a massive sort operation that finished).
Coalescing: It merges free space in data files to make it easier for Oracle to find large chunks of contiguous space.
The Cleanup Crew
If SMON monitors the system, PMON monitors the users. It watches over the individual user processes connecting to the database.
Handling Crashed Users: If a user’s laptop dies or their network connection drops while they have an active transaction, PMON notices. It rolls back their uncommitted changes and releases the "locks" they were holding so other users aren't stuck waiting.
Listener Registration: PMON also talks to the Oracle Listener, telling it, "Hey, I'm here and ready to accept new connections!"
| Process | Full Name | Primary Responsibility | Critical Moment |
| DBWn | Database Writer | Writes data blocks to disk. | When the Buffer Cache is full. |
| LGWR | Log Writer | Writes transaction logs to disk. | Every time you COMMIT. |
| SMON | System Monitor | Cleans up system/Instance recovery. | During Database Startup. |
| PMON | Process Monitor | Cleans up failed user sessions. | When a user disconnects abruptly. |
If any of these four processes fail or are "killed" at the OS level, the entire Oracle Instance will usually crash immediately as a safety precaution to prevent data corruption. They are the vital organs of the database!