Symptom
Users report that saves and short transactions are slow. AWR or ASH puts log file sync in the top waits, sometimes at 5–50 ms average when it is normally under 1–2 ms. Throughput drops at peak and recovers off-peak.
log file sync is time spent by a foreground session waiting, after COMMIT, for LGWR to confirm that its redo is on disk. That's the user's whole commit wait. It contains the following:
- Posting LGWR, and LGWR getting on CPU.
- LGWR writing the redo (this part is
log file parallel write). - LGWR posting the foreground back, and the foreground getting on CPU.
The fix depends on which part is slow.
Check 1: compare sync against parallel write
SELECT event, total_waits,
round(time_waited_micro / nullif(total_waits, 0) / 1000, 2) AS avg_ms
FROM v$system_event
WHERE event IN ('log file sync', 'log file parallel write')
ORDER BY event;
The cumulative figures hide peaks. Use the histogram, and compare AWR snapshots across the slow window:
SELECT event, wait_time_milli, wait_count
FROM v$event_histogram
WHERE event IN ('log file sync', 'log file parallel write')
ORDER BY event, wait_time_milli;
| Pattern | Meaning | Go to |
|---|---|---|
log file parallel write average is close to log file sync and both are high | Redo writes are slow | Fix 1: storage |
log file parallel write is low but log file sync is much higher | Time lost outside the write: CPU, scheduling, post/wait | Fix 3: CPU |
Both are low per wait but log file sync total time is huge | Too many commits | Fix 2: commit pattern |
Check 2: commit rate and redo per commit
SELECT name, value
FROM v$sysstat
WHERE name IN ('user commits', 'user rollbacks', 'redo size',
'redo synch writes', 'redo synch time (usec)', 'redo writes');
Take the deltas over a minute, or use the AWR "Load Profile" section. If redo per commit is tiny (a few hundred bytes) and commits run to thousands per second, the application is committing per row. Find the offenders:
SELECT sql_id, session_id, program, module, count(*) AS samples
FROM v$active_session_history
WHERE event = 'log file sync'
AND sample_time > systimestamp - interval '30' minute
GROUP BY sql_id, session_id, program, module
ORDER BY samples DESC FETCH FIRST 15 ROWS ONLY;
In ASH, sql_id for these samples is often the statement before the commit, or NULL. module and program are usually the better pointers.
Check 3: LGWR's own view
The LGWR trace file reports slow writes and changes in commit notification mode:
SELECT value FROM v$diag_info WHERE name = 'Diag Trace';
cd /u01/app/oracle/diag/rdbms/prod/PROD/trace
grep -h "Warning: log write elapsed time" *_lgwr_*.trc | tail -20
grep -hiE "polling|post/wait" *_lgwr_*.trc | tail -20
Warning: log write elapsed time NNNms, size NNKB confirms slow I/O at the moment it happened. Lines about switching between polling and post/wait come from adaptive log file sync, which is on by default. Frequent switches under load can add latency. Work through it with Oracle Support rather than changing hidden parameters yourself.
From 12c, LGWR can use helper processes (LG00, LG01 and so on) for scalable log writing. Check whether they exist and how busy they are:
SELECT pname, spid FROM v$process WHERE pname LIKE 'LG%' ORDER BY pname;
Also check the redo log layout and switch rate, because a slow log file switch makes things worse:
SELECT group#, thread#, bytes/1024/1024 AS mb, members, status FROM v$log;
SELECT trunc(first_time, 'HH24') AS hour, count(*) AS switches
FROM v$log_history
WHERE first_time > sysdate - 1
GROUP BY trunc(first_time, 'HH24') ORDER BY 1;
Fix 1: slow redo writes
- Put the online redo logs on the lowest-latency storage you have. Keep them off volumes shared with archive logs, backups or datafile-heavy I/O. On cloud block storage, check that the volume isn't hitting its IOPS or throughput cap during peaks.
- Multiplexed members (
members > 1) mean each write waits for the slowest member. Put members on independently fast devices, not one fast and one slow. - Check the OS view:
iostat -x 5latency (w_await) on the redo devices during the slow window. - With synchronous Data Guard (
SYNC AFFIRM), the commit also waits for the standby. Look atSYNC Remote Writeand the redo transport waits in AWR. Network latency to the standby adds directly to commit time.
Fix 2: too many commits
The real fix is in the application: commit per business transaction or per batch of rows, not per row. For batch jobs where losing the last few transactions after an instance crash is acceptable, Oracle lets a session skip the wait:
-- Session level, for a specific batch job only
ALTER SESSION SET commit_logging = 'BATCH';
ALTER SESSION SET commit_wait = 'NOWAIT';
Caution
COMMIT_WAIT = NOWAITreturns before the redo is durable. If the instance crashes, transactions the application saw as committed can be lost. Never set it at system level for OLTP, and only use it per session where the job can safely re-run.
Fix 3: CPU starvation
When log file parallel write is fast but log file sync is slow, LGWR or the foregrounds are waiting for CPU.
- Check the host run queue (
vmstat 5, thercolumn against the CPU count) and AWR "Host CPU". If the host is saturated, fix that load first: top SQL by CPU, or too many active sessions from an oversized connection pool. - Resource Manager limits, or noisy-neighbour VMs, can slow LGWR's scheduling too.
- Raising LGWR priority with
_high_priority_processesis an unsupported change. Do it only with guidance from Oracle Support.
Redo log size is a separate issue
Small redo logs cause frequent switches (log file switch (checkpoint incomplete), log file switch completion). They don't directly cause slow log file sync. Size the logs so switches happen roughly every 15–20 minutes at peak, by adding new larger groups and dropping the old ones once they're INACTIVE:
ALTER DATABASE ADD LOGFILE THREAD 1 GROUP 11 ('+REDO') SIZE 4G;
-- repeat per group/thread, then after switches:
ALTER SYSTEM SWITCH LOGFILE;
ALTER SYSTEM CHECKPOINT;
ALTER DATABASE DROP LOGFILE GROUP 1; -- only when status = INACTIVE
The 4 GB in the example is only an example. Work out the size from your peak redo rate.
Prevent it next time
- Alert on
log file parallel writeaverage latency, not justlog file sync. That way storage problems show up before users feel them. - Track commits per second and redo per commit for each major application module, and review any new batch job for per-row commits before release.
- Keep redo on its own low-latency storage class in your platform standard, and recheck the cloud volume limits when the workload grows.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get