In an ongoing effort to document the main Oracle wait events, here is my current effort at documenting Oracle's redo log related wait events. The original article is at
http://sites.google.com/site/embtdbo
and I will be making additional change and adding content as I have time.
Redo
In an ongoing effort to document the main Oracle wait events, here is my current effort at documenting Oracle's redo log related wait events. The original article is at
http://sites.google.com/site/embtdbo
and I will be making additional change and adding content as I have time.
Redo
Redo is written to disk when
User commitsLog Buffer 1/3 full (_log_io_size)Log Buffer fills 1MEvery 3 secondsDBWR asks LGWR to flush redo
Sessions Commiting wait for LGWR
Redo Log Wait Events
Log file Sync
CommitRollback
Arguments
P1 = buffer# in log buffer that needs to be flushedP2 = not usedP3 = not used
Commit less
Often possible in loops that commit every loop
Commit every 50 or 100 instead
Put redo on dedicated diskUse Raw Device or Direct IOMore Radical
Consider Ram DisksCan stripe if redo writes are comparable to stripe size
Striping shouldn’t hurtStriping can help
Ex: imp – can have large redo writes – can improve by 10-30%
Alternate disks for redo and archiving of redoPossibly 10gR2
ALTER SYSTEM SET COMMIT_WRITE = BATCH, NOWAIT
Commit could be lost if machine crashOr IO error
Solution
Increase log_buffer parameter in init.ora
Above 3M log_buffer little affect, if still a problem then backup is at disk level
Improve disk IO for redo
Faster diskRaw fileDirect IODedicated disk
p1, p2, p3 – no values
No p1,p2,p3Database “hangs” for transactionsarchive log stop;-- make room in log_archive_destarchive log start;
Wait for checkpoint to complete because all log files are fullSolutionsAdd more log filesIncrease size of log files
New wait 10gLike a “log file switch Completion”
Wait for lgwr to switch log files when generating redoSolution:
Increase redo log file size
Reduces frequency of switches
What happens when a log file switch occurs:
Get next log file from control fileGet Redo Copy and Redo Allocation latchFlush redoClose FileUpdate Controlfile
Set new file to CurrentSet old file to ActiveIf in Archivelog mode add file to archive listOpen all members of new logfile groupWrite the SCN to the headersEnable redo log generation
DBWR makes a list of blocks that need to be written out in order to over write the Redo log file a list of blocks that need to be written out in order to over write the Redo log file
Same as log file switch completion but the command is executed by the dbaAlter system switch logfile;
What happens to recovery time if I change my redo log file sizes
Larger Redo Log size can increase recovery time but
There are init.ora parameters to limit this
Standby DB: ARCHIVE_LAG_TARGET
Seconds, limits lag between primary and standby
Increases log file switches
FAST_START_MTTR_TARGET
Seconds to Recovery
Easy and accuracy
Is overridden by FAST_START_IO_TARGET
Is overridden by LOG_CHECKPOINT_INTERVAL
alter system set fast_start_mttr_target=17 scope=both;
SQL> select ESTIMATED_MTTR from V$INSTANCE_RECOVERY;
ESTIMATED_MTTR
--------------
21
Kyle,
ReplyDeletethank you for this great set of posts.
In this particular, you comment to commit less in PL/SQL to reduce "Log file Sync". But from 10g onwards (or before?) Oracle seems to do internally a 'commit nowait' in pl/sql until the end of the procedure.
http://www.oracledba.co.uk/tips/lgwr_dilemma.htm
best regards,
Martin
yes, AFAIK the PL/SQL idiosyncrasy has always been there.
ReplyDeleteYes, the commit less often only applies to non-PL/SQL code. I'll correct the text - thanks.
As mentioned, one can take "advantage" of this pl/sql peculiarity out side if pl/sql with
ALTER SYSTEM SET COMMIT_WRITE = NOWAIT;
"ALTER SYSTEM SET COMMIT_WRITE = NOWAIT;"
ReplyDeleteOn many busy systems ... this is like riding a tiger.
Damir Vadas
http://damir-vadas.blogspot.com