Sub topic 13
COMMIT WRITE Options for Redo Durability Trade-offs
Prerequisites
This chapter assumes that you know basic SQL and understand that COMMIT ends the current transaction. You should also know that Oracle records changes in redo data so it can recover committed work after a failure.
What COMMIT WRITE controls
When a session commits, Oracle must make the transaction's redo available to the database writer process, called LGWR. LGWR writes redo from memory to the online redo log files.
COMMIT WRITE controls when Oracle asks LGWR to write redo and when the committing session waits for that write. It does not change which statements belong to the transaction.
COMMIT WRITE IMMEDIATE WAIT;
COMMIT WRITE BATCH WAIT;
COMMIT WRITE IMMEDIATE NOWAIT;
COMMIT WRITE BATCH NOWAIT;The two choices have separate meanings:
IMMEDIATEasks Oracle to write the commit redo without deliberately waiting to group it with later commits.BATCHpermits Oracle to group the redo with other commit requests.WAITmakes the session wait until the redo is written successfully.NOWAITlets the session continue before that redo write finishes.
The usual default is IMMEDIATE WAIT, although database configuration can affect default commit behavior. Explicit options make the intent of an individual commit clear.
Comparing the options
| Option | Redo write request | Session waits? | Main trade-off |
|---|---|---|---|
| `IMMEDIATE WAIT` | Promptly | Yes | Strong durability with more commit latency |
| `BATCH WAIT` | Grouped when possible | Yes | May improve throughput while preserving wait behavior |
| `IMMEDIATE NOWAIT` | Promptly | No | Lower latency with crash-related durability risk |
| `BATCH NOWAIT` | Grouped when possible | No | Highest throughput potential and highest timing uncertainty |
WAIT is the important choice for ordinary business transactions. When it returns successfully, the commit redo has reached the redo log according to the database's durability guarantees.
NOWAIT improves response time because the application does not wait for the physical redo write. However, a power failure or instance crash could occur after the application receives success but before the redo is safely written. The transaction might then be lost during recovery.
Choosing IMMEDIATE or BATCH
IMMEDIATE is useful when the commit should request a redo write promptly. BATCH can help workloads that perform many small commits because LGWR can combine requests into fewer writes.
Neither option removes the need for good transaction design. A transaction that commits once per row may still perform poorly, even with BATCH. Grouping related changes into one business transaction usually reduces overhead and preserves consistency.
UPDATE accounts
SET balance = balance - 100
WHERE id = 1;
UPDATE accounts
SET balance = balance + 100
WHERE id = 2;
COMMIT WRITE BATCH WAIT;The two updates become permanent together. BATCH WAIT changes the redo-write timing, not the atomicity of the transfer.
Visibility and failure behavior
A successful commit releases the transaction's locks and makes its changes available to other sessions. With NOWAIT, those effects can become visible before the commit redo has been written to stable storage. That is the central trade-off: fast acknowledgment in exchange for weaker protection against an instance failure.
Practical guideline
Use WAIT unless you have measured a commit-latency problem and can explain the recovery consequences. Consider BATCH WAIT for high-throughput workloads after testing it under realistic concurrency. Treat NOWAIT as an opt-in durability compromise, not as a general performance setting.
Exercise
Which option should an order-processing transaction normally use when a successful response must mean that the order survives an instance crash?
Show answer
Use COMMIT WRITE WAIT, commonly the default IMMEDIATE WAIT. Avoid NOWAIT because the response can return before the commit redo is safely written.