Instance Architecture   «Prev  Next»

                                   
Lesson 14The Log Writing Process
ObjectiveExplain the functions of the head and tail pointers in the redo log buffer.

Log-Writing Process: Head and Tail of the Redo Buffer (LGWR)

The redo log buffer in the SGA is a circular queue. Two pointers describe its state:

As transactions generate redo, the head advances. LGWR continuously drains from the tail, writing sequentially to the online redo logs. On COMMIT, LGWR ensures that all redo for the committing transaction is on durable storage (write-ahead logging). Data block writes are decoupled and handled later by DBWn.

Head/Tail Timeline (9-step visual)

When LGWR flushes

Data Guard & transport mode (LGWR vs ARCH)

For protected configurations, redo can be shipped to standbys:

-- Example: primary sending real-time redo to a standby
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2 =
  'SERVICE=stby1 ASYNC NOAFFIRM LGWR VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
   DB_UNIQUE_NAME=STBY1' SCOPE=BOTH;

-- Force an immediate switch/ship if needed
ALTER SYSTEM ARCHIVE LOG CURRENT;

Monitoring & troubleshooting

-- Redo volume, commit counts, and LGWR work
SELECT name, value
FROM   v$sysstat
WHERE  name IN ('redo size','redo writes','redo write time','user commits');

-- Session wait vs. device wait (commit path)
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;

-- Online redo groups and members (multiplexing)
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 log switches (cadence helps checkpoint stability)
SELECT sequence#, first_time, next_time
FROM   v$log_history
ORDER  BY first_time DESC
FETCH FIRST 20 ROWS ONLY;

Practical guidance

  1. Place redo on low-latency storage and keep its queue depth healthy.
  2. Right-size redo logs for a steady switch interval (avoid thrash and multi-hour gaps).
  3. Batch commits when possible to benefit from group commit (without changing durability semantics).
  4. Choose transport mode (LGWR vs ARCH; SYNC vs ASYNC) to match RPO/RTO needs.

Usefulness and Modernization Notes


Log Writing Process - Quiz

Click the Quiz link below to take a short a quiz covering the LGWR process.
Log Writing Process - Quiz

SEMrush Software 14 SEMrush Banner 14