Oracle 10g Performance: chapter 08 redo
-
Upload
kyle-hailey -
Category
Education
-
view
115 -
download
0
description
Transcript of Oracle 10g Performance: chapter 08 redo
#.2Copyright 2006 Kyle Hailey
In This Section:
1. Log Buffer Space
2. Log File Sync
3. Log File Switch Completion
4. Log File Switch (checkpoint incomplete)
5. Log File Switch (private strand flush incomplete)
6. Log File Switch (archiving needed)
7. Switch Log File Command
#.3Copyright 2006 Kyle Hailey
Log File Waits
REDO Log FilesREDO Log Files Data FilesData Files
DBWRDBWRLGWRLGWR
User2User2
User1User1
User3User3
Log BufferLog Buffer
Buffer CacheBuffer CacheLog Log BufferBuffer
Buffer Buffer CacheCache
SGASGALibrary Library CacheCache
#.4Copyright 2006 Kyle Hailey
Log File Operations
Redo is written to disk whenUser commitsLog Buffer 1/3 full (_log_io_size)Log Buffer fills 1MEvery 3 secondsDBWR asks LGWR to flush redo
Sessions Commiting wait for LGWR
#.5Copyright 2006 Kyle Hailey
log buffer space
Wait for space in the redo log buffer in SGA Solution
1. Increase log_buffer parameter in init.ora Above 3M log_buffer little affect, if still a problem then
backup is at disk level
2. Improve disk IO for redo Faster disk Raw file Direct IO Dedicated disk
p1, p2, p3 – no values
#.6Copyright 2006 Kyle Hailey
Log Buffer Space
REDO Log FilesREDO Log Files
Log BufferLog Buffer
LGWRLGWR
Buffer CacheBuffer Cache
User2User2
User1User1
User3User3
Insert Insert UpdateUpdatedeletedelete
Log Log BufferBuffer
Buffer Buffer CacheCache
SGASGALibrary Library CacheCache
1.1. Log Buffer too smallLog Buffer too small
2.2. LGWR too slowLGWR too slow
Slow diskSlow disk
#.7Copyright 2006 Kyle Hailey
log file sync
Wait for redo flush upon:CommitRollback
ArgumentsP1 = buffer# in log buffer that needs to be flushedP2 = not usedP3 = not used
select parameter1, parameter2, parameter3 select parameter1, parameter2, parameter3 from v$event_namefrom v$event_namewhere name=‘log file sync';where name=‘log file sync';
PARAMETER1 PARAMETER2 PARAMETER3PARAMETER1 PARAMETER2 PARAMETER3
---------- ---------- -------------------- ---------- ----------
buffer#buffer#
#.8Copyright 2006 Kyle Hailey
Log File Sync
REDO Log FilesREDO Log Files Data FilesData Files
DBWRDBWRLGWRLGWR
User2User2
User1User1
User3User3
Commit;Commit;
wait for LGWRwait for LGWR
Log Log BufferBuffer
Buffer Buffer CacheCache
SGASGALibrary Library CacheCache
#.9Copyright 2006 Kyle Hailey
Log File Sync: Solutions Commit less
Often possible in loops that commit every loop Commit every 50 or 100 instead
Possibly 10gR2 ALTER SYSTEM SET COMMIT_WRITE = BATCH, NOWAIT
Commit could be lost if machine crash or IO error Improve IO
Use Raw Device or Direct IO Consider Ram Disks Can stripe if redo writes are comparable to stripe size
Striping shouldn’t hurt Striping can help
Ex: imp – can have large redo writes – can improve by 10-30%
Alternate disks for redo and archiving of redo
(_high_priority_processes)
#.10
Log File Sync depends on:
log file parallel writeTime it takes for LGWR to write out changes
If log file sync =~ log file parallel writeAnd the time is slow ( > 3ms) look into IO issues
If log file sync >> log file parallel writeLook at CPU starvation issues
Copyright 2006 Kyle Hailey
#.11Copyright 2006 Kyle Hailey
Separating LGWR and ARCH
Redo 1Redo 1
Redo 3Redo 3
Redo 2Redo 2
Redo 4Redo 4
LGWRLGWR ARCHARCH
#.12Copyright 2006 Kyle Hailey
Log file switch completion
No p1,p2,p3 Wait for lgwr to switch log files when generating
redo Solution:
Increase redo log file size Reduce frequency of switches
#.13
User3User3
Copyright 2006 Kyle Hailey
log file switch completion
REDO Log FilesREDO Log Files Data FilesData Files
Log BufferLog Buffer
DBWRDBWRLGWRLGWR
Buffer CacheBuffer Cache
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx
Wait : log file switch completion
User2User2
User1User1
Commit;Commit;
Wait for Wait for LGWRLGWR
Log Log BufferBuffer
Buffer Buffer CacheCache
SGASGALibrary Library CacheCache
11 22 33
Sessions Sessions writing redo writing redo wait while wait while switch happensswitch happens
#.14Copyright 2006 Kyle Hailey
log file switch (checkpoint incomplete)
No p1,p2,p3 args Wait for checkpoint to complete because all log
files are full Solutions
Increase size of log files
#.15Copyright 2006 Kyle Hailey
log file switch (checkpoint incomplete) : Diag
REDO Log FilesREDO Log Files Data FilesData Files
Log BufferLog Buffer
LGWRLGWR
Buffer CacheBuffer Cache
Checkpoint 1Checkpoint 1
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx
Checkpoint 2Checkpoint 2
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx
Checkpoint 3Checkpoint 3
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx
DBWRDBWR
Log Log BufferBuffer
Buffer Buffer CacheCache
SGASGALibrary Library CacheCache
11
22
33
33
Sessions Sessions writing redo writing redo wait while wait while switch switch ANDAND checkpoint checkpoint happenhappen
User3User3
User2User2
User1User1
Commit;Commit;
Wait for Wait for LGWRLGWR
#.16Copyright 2006 Kyle Hailey
log file switch (archiving needed)
No p1,p2,p3 Database “hangs” for transactions
archive log stop;
-- make room in log_archive_dest
archive log start;
#.17Copyright 2006 Kyle Hailey
log file switch (archiving needed) :
REDO Log FilesREDO Log Files Archive DestArchive Dest
ARCHARCH
LGWRLGWR
Log BufferLog Buffer
Buffer CacheBuffer Cache
Log BufferLog Buffer
Buffer CacheBuffer CacheLog Log BufferBuffer
Buffer Buffer CacheCache
SGASGALibrary Library CacheCache
33
#.18Copyright 2006 Kyle Hailey
switch logfile command
Same as log file switch completion but the command is executed by the dbaAlter system switch logfile;
#.19Copyright 2006 Kyle Hailey
Concerns – Recovery Time
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
#.20Copyright 2006 Kyle Hailey
Incremental Checkpoints (9iR2+)
FAST_START_MTTR_TARGET Seconds to RecoveryEasy and accuracy Is overridden by FAST_START_IO_TARGET Is overridden by LOG_CHECKPOINT_INTERVAL
SQL> select ESTIMATED_MTTR from V$INSTANCE_RECOVERY;
ESTIMATED_MTTR-------------- 21
SQL> select ESTIMATED_MTTR from V$INSTANCE_RECOVERY;
ESTIMATED_MTTR-------------- 21
alter system set fast_start_mttr_target=17 scope=both;alter system set fast_start_mttr_target=17 scope=both;
#.21Copyright 2006 Kyle Hailey
Recovery and Checkpoints
REDO Log FilesREDO Log Files
Data FilesData Files
DBWRDBWR
LGWRLGWR
Log Log BufferBuffer
Buffer Buffer CacheCache
SGASGALibrary Library CacheCache
Incremental CheckpointIncremental Checkpoint
Current PositionCurrent Position
Needed for RecoveryNeeded for Recovery11 22 33
#.22Copyright 2006 Kyle Hailey
DBWR dirty List and LGWR
Buffers
Checkpoint aCheckpoint a
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx
DBWRDBWR
LGWR Current LGWR Current PositionPosition
Incremental CheckpointIncremental CheckpointDBWRDBWR
DBWR usually DBWR usually just writes out just writes out dirty blocks at dirty blocks at end of LRU end of LRU until checkpointuntil checkpoint
Now, DBWR Now, DBWR keeps a keeps a checkpoint list that checkpoint list that it writes outit writes out
#.23Copyright 2006 Kyle Hailey
DBWR dirty List
MRU - HotMRU - Hot LRU - ColdLRU - ColdBuffer Headers
Dirty ListDirty List
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx
DBWRDBWR
DBWR also has to DBWR also has to track dirty blocks at the track dirty blocks at the cold end of the LRU cold end of the LRU
#.24Copyright 2006 Kyle Hailey
DBWR merges Dirty and Checkpoint
MRU - HotMRU - Hot LRU - ColdLRU - ColdBuffer Headers
Dirty ListDirty List
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx
DBWRDBWRCheckpoint aCheckpoint a
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx
Write ListWrite List
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx Data FilesData Files
#.25Copyright 2006 Kyle Hailey
log file switch (private strand flush incomplete)
New wait 10g Like a “log file switch Completion”
#.26Copyright 2006 Kyle Hailey
Redo Wait Solutions log file sync
Commit less, put redo logs on faster disks
log buffer spaceIncrease log buffer no more than 32M, then tune LGWR
log file switch completionIncrease log file sizes
log file switch (checkpoint incomplete)Add log files (or increase log file size)
switch logfile commandAvoid switching log files
log file switch (private strand flush incomplete)
increase log file sizes
log file switch (archiving needed) ***Archive log running out of space