Question: I understand that there are times
that you need to force a log switch for backups, but I have noted
that Oracle has two ways to force a logfile switch, ALTER SYSTEM
SWITCH LOGFILE and ALTER SYSTEM ARCHIVELOG CURRENT.
What is the difference between
ALTER SYSTEM SWITCH LOGFILE and ALTER SYSTEM ARCHIVELOG CURRENT,
and when do I use each?
Answer: Yes, both
ALTER SYSTEM SWITCH LOGFILE and ALTER SYSTEM ARCHIVELOG CURRENT
will force a log switch, but they do it in different ways!
Both the SWITCH LOGFILE and ARCHIVELOG CURRENT write a quiesce
checkpoint, a firm place whereby that last redo log is a part of the
hot backup, but ARCHIVELOG CURRENT waits for the writing to
complete. This can take several minutes for multi-gigabyte redo
logs.
Conversely, the ALTER SYSTEM SWITCH LOGFILE command is very fast
and returns control to the caller in less than a second while ALTER
SYSTEM ARCHIVELOG CURRENT pauses.
As we see below, the ALTER SYSTEM SWITCH LOGFILE is fast because
it does not wait for the archiver process (ARCH) to complete writing
the online redo log to the archivelog log filesystem:
- It issues database checkpoint
- It immediately starts writing to the next redo log
- In the background, the “switch logfile” command tells
the ARCH background process to copy the “old” redo log file to
the redo log filesystem.
Here are the important differences between
ALTER SYSTEM SWITCH LOGFILE and ALTER SYSTEM ARCHIVELOG CURRENT:
- RAC: If you are running RAC, the
ALTER SYSTEM ARCHIVELOG CURRENTwill switch the logs on
all RAC nodes (instances), whereas
ALTER SYSTEM SWITCH LOGFILE will only switch he logfile
on the instance where you issue the switch command. Hence,
ALTER SYSTEM ARCHIVELOG CURRENT is a best practice for
RAC systems.
- ALTER SYSTEM SWITCH LOGFILE is
asynchronous: This command is fast to return to the invoking
program because the writing of the redo log to the OS filesystem
is done in the background. There is a very small risk in cases
where the ARCH process cannot complete writing the redo log,
such as cases where the OS archivelog file directory is out of
space. It is also risky because the calling script may move on
to a subsequent step, assuming that the redo has been written.
Some scripts will place a SLEEP 60 command in their backup
script to allow time for the redo to complete writing, but this
is not a best practice.
- ALTER SYSTEM ARCHIVELOG CURRENT is
synchronous: This is faster to return because this command
waits until the online redo log has completed the writing of the
redo log file to the filesystem. This command is safer because
it waits for the OS to acknowledge (ACK) that the redo log has
been successfully written. Hence,
ALTER SYSTEM ARCHIVELOG CURRENT is the best practice for
production backup scripts with RMAN.
- Argument required: The
ALTER SYSTEM ARCHIVELOG CURRENT allows you to specify the
thread to archive while the
ALTER SYSTEM SWITCH LOGFILE archives only the current
thread. If you do not pass the thread parameter, Oracle will
archive all full online redo logs.
|
|
|
|
Guarantee your Success!
Oracle is the
world's most complex, robust and flexible database, considered
impossible to master without a mentor.
That's why all BC
Oracle trainers are working professionals, experts in Oracle who
share their tips and secrets. |
|
| |
|
Burleson is the American Team

Note:
This Oracle
documentation was created as a support and Oracle training reference for use by our
DBA performance tuning consulting professionals.
Feel free to ask questions on our
Oracle forum.
Verify
experience!
Anyone
considering using the services of an Oracle support expert should
independently investigate their credentials and experience, and not rely on
advertisements and self-proclaimed expertise. All legitimate Oracle experts
publish
their Oracle
qualifications.
Errata?
Oracle technology is changing and we
strive to update our BC Oracle support information. If you find an error
or have a suggestion for improving our content, we would appreciate your
feedback. Just
e-mail:
and include the URL for the page.
Copyright ? 1996 - 2012
All rights reserved.
Oracle ?
is the registered trademark of Oracle Corporation.
|
|