Oracle 10g Performance: chapter 08 redo

26
#.1 Redo Waits Kyle Hailey http://perfvision.com/ftp/ emea2010 [email protected]

description

 

Transcript of Oracle 10g Performance: chapter 08 redo

Page 1: Oracle 10g Performance: chapter 08 redo

#.1

Redo Waits

Kyle Hailey

http://perfvision.com/ftp/emea2010

[email protected]

Page 2: 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

Page 3: Oracle 10g Performance: chapter 08 redo

#.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

Page 4: Oracle 10g Performance: chapter 08 redo

#.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

Page 5: Oracle 10g Performance: chapter 08 redo

#.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

Page 6: Oracle 10g Performance: chapter 08 redo

#.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

Page 7: Oracle 10g Performance: chapter 08 redo

#.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#

Page 8: Oracle 10g Performance: chapter 08 redo

#.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

Page 9: Oracle 10g Performance: chapter 08 redo

#.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)

Page 10: Oracle 10g Performance: chapter 08 redo

#.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

Page 11: Oracle 10g Performance: chapter 08 redo

#.11Copyright 2006 Kyle Hailey

Separating LGWR and ARCH

Redo 1Redo 1

Redo 3Redo 3

Redo 2Redo 2

Redo 4Redo 4

LGWRLGWR ARCHARCH

Page 12: Oracle 10g Performance: chapter 08 redo

#.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

Page 13: Oracle 10g Performance: chapter 08 redo

#.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

Page 14: Oracle 10g Performance: chapter 08 redo

#.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

Page 15: Oracle 10g Performance: chapter 08 redo

#.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

Page 16: Oracle 10g Performance: chapter 08 redo

#.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;

Page 17: Oracle 10g Performance: chapter 08 redo

#.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

Page 18: Oracle 10g Performance: chapter 08 redo

#.18Copyright 2006 Kyle Hailey

switch logfile command

Same as log file switch completion but the command is executed by the dbaAlter system switch logfile;

Page 19: Oracle 10g Performance: chapter 08 redo

#.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

Page 20: Oracle 10g Performance: chapter 08 redo

#.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;

Page 21: Oracle 10g Performance: chapter 08 redo

#.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

Page 22: Oracle 10g Performance: chapter 08 redo

#.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

Page 23: Oracle 10g Performance: chapter 08 redo

#.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

Page 24: Oracle 10g Performance: chapter 08 redo

#.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

Page 25: Oracle 10g Performance: chapter 08 redo

#.25Copyright 2006 Kyle Hailey

log file switch (private strand flush incomplete)

New wait 10g Like a “log file switch Completion”

Page 26: Oracle 10g Performance: chapter 08 redo

#.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