Total Pageviews

Monday, 21 May 2012

ALTER SYSTEM SWITCH LOGFILE vs ALTER SYSTEM ARCHIVELOG CURRENT

 Both ALTER SYSTEM SWITCH LOGFILE(Asynchronous) and ALTER SYSTEM ARCHIVELOG 
 CURRENT(Synchronous) will force a log switch, but they do it in different 
 ways!
The 'ALTER SYSTEM ARCHIVELOG CURRENT' is the preferred one that should be
used for backup scripts. 
The reason being,when you do an 'ALTER SYSTEM SWITCH
LOGFILE', you get the prompt back immediately. This command performs a
database checkpoint, switches to the next log, In background signals the 
archiver to copy the logfile to the archive destination, and returns the 
prompt. Mind you,this command does not wait for the archive to complete. 
As the command indicates, it only performs a log switch. Hence, you might 
come across backup scripts which does an 'ALTER SYSTEM SWITCH LOGFILE' and 
then does a SLEEP for some time, thus allocating some time for the Archiver 
to finish archiving. 
Whereas, an 'ALTER SYSTEM ARCHIVE LOG CURRENT' does all of the
above, but does not return back to the prompt until the archive is
complete.This command is safer because it waits for the OS to acknowledge(ACK) 
that the redo log has been successfully written.
Also, 'ALTER SYSTEM SWITCH LOGFILE' archives only the current thread.
Whereas the 'ALTER SYSTEM ARCHIVELOG CURRENT' needs a thread to be
specified and If you miss the thread parameter, Oracle archives all redo
log file groups from all enabled threads, including logs previous to
current logs.  

No comments:

Post a Comment