Instance Architecture   «Prev  Next»

Lesson 13 The Log Writer (LGWR)
Objective Describe how Log Writer writes out redo log records.

Log Writer (LGWR): Commit Durability, Flush Triggers, and Tuning

Circular redo log buffer with head and tail pointers and numbered entries
  • Head of the log: where new redo entries are appended.
  • Tail of the log: next redo entry that LGWR will write to disk.
  • 113,112,111: old entries, long since written.
  • 903,902,901: recently written to disk.
  • 998,997 … 906,905: waiting in the buffer to be written.
  • 904: the next entry to be written.
  • 999: most recently appended entry.

LGWR is the single background process that guarantees commit durability. It sequentially writes redo from the redo log buffer (in the SGA) to the online redo logs on disk. Data block writes are decoupled-those are DBWn’s job- so COMMIT returns success as soon as LGWR confirms the redo is on persistent storage (write-ahead logging).

When does LGWR write?

What LGWR actually writes

Group commit, clarified

If commits arrive quickly, LGWR batches them into one I/O. Each transaction still observes full durability semantics, but many commits share the same physical write, lowering IOPS and latency variance.

LGWR vs. DBWn (don’t mix them up)

Data Guard note

In protected configurations, LGWR can stream redo to standbys (SYNC/ASYNC). Standby transport/ack policies affect COMMIT latency; choose settings that match RPO/RTO goals.

Monitoring and Diagnostics

-- High-level redo activity
SELECT name, value
FROM   v$sysstat
WHERE  name IN ('redo size', 'redo writes', 'redo write time',
                'user commits', 'redo wastage');

-- Commit and LGWR wait profiling (system-wide since startup)
SELECT event, total_waits, time_waited/100 AS seconds_waited
FROM   v$system_event
WHERE  event IN ('log file sync','log file parallel write')
ORDER  BY time_waited DESC;

-- Current online redo log status/cycling
SELECT l.group#, l.bytes/1024/1024 AS size_mb, l.status, lf.member
FROM   v$log l
JOIN   v$logfile lf USING (group#)
ORDER  BY l.group#, lf.member;

-- Recent switch cadence (helps right-size log files)
SELECT sequence#, first_time, next_time
FROM   v$log_history
ORDER  BY first_time DESC
FETCH FIRST 20 ROWS ONLY;

Tuning Playbook (commit latency and throughput)

  1. Place redo on low-latency storage; separate from datafiles/flash for predictable write times.
  2. Right-size online redo logs to achieve a steady switch interval (avoid thrash or hour-long gaps).
  3. Avoid excessive per-row commits; batch work where semantics allow to benefit from group commit.
  4. Validate async I/O and queue depth on the redo device; watch log file parallel write times.
  5. Be cautious with COMMIT WRITE settings (e.g., NOWAIT/BATCH); only change if you fully understand durability and ordering implications.

Common misconceptions

SEMrush Software 13 SEMrush Banner 13