Simpler Navigation coming for Servers and Operating Systems
Coming soon: a much simpler Servers and Operating Systems section of the Community. We will combine many of the older boards, and you won't have to click through so many levels to get at the information you need. If you are looking for an older board and do not find it, check the consolidated boards, as the posts are still there.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

Why oracle LGWR process should write redo log file before DBW0 process flush buffer cache?

SOLVED
Go to solution
稀里哗啦
Advisor

Why oracle LGWR process should write redo log file before DBW0 process flush buffer cache?

I don't know what is the benifit from this action.
5 REPLIES
Tom Geudens
Honored Contributor
Solution

Re: Why oracle LGWR process should write redo log file before DBW0 process flush buffer cache?

Hi,
Imagine a database crash. You want to recover your database up to the last committed data. You restore your last fullbackup and start playing back ... the redologs. And that's the reason. Funny as it may sound, but for Oracle it's more important (relatively speaking off course :-) that the redolog gets written than that the actual database page gets written.

Hope this explains,
Tom
A life ? Cool ! Where can I download one of those from ?
Brian Crabtree
Honored Contributor

Re: Why oracle LGWR process should write redo log file before DBW0 process flush buffer cache?

Well, hopefully I wont get to deep into this, but I will try to answer generally. In this case, you have it backwards. When oracle triggers a log switch (called a checkpoint BTW), it forces the buffer cache to write all dirty buffers to the disk.

While oracle is running, it allows processes to update data in the memory structure rather than update data on the disk due to the cost increase. While this is helpful on the surface by increasing the speed at which a process will come back to you, it does mean that what the database on disk is and what is true in memory is not in sync.

The reason the the checkpoint is flushed at that point, is so that the log in question is concurrent with the database, and can be used in a recovery situation (if that log were the last log used in a point-in-time recovery). Checkpoints can be forced either manually, or by setting the "LOG_CHECKPOINT_TIMEOUT" or "LOG_CHECKPOINT_INTERVAL" in the init.ora.

I hope this answers some of your questions.

Thanks,

Brian
Thierry Poels_1
Honored Contributor

Re: Why oracle LGWR process should write redo log file before DBW0 process flush buffer cache?

Hi,

next to data integrity, which already has been mentioned, think about SPEED!

A data block might get updated in memory several times before effectively being written to disk.

regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Simeon Fox
Advisor

Re: Why oracle LGWR process should write redo log file before DBW0 process flush buffer cache?

This is one the key features of Oracle. Redo logs record all changes made to the datbase. The redo logs are a straight dump of the O/S blocks and can be written instantly to disk. The more complex operation of writing to the oracle datafiles can be safely deferred - the so-called "lazy write". With performance in mind, Oracle never does more disk writing than it needs to - it is the continuous flushing of the redo logs to disk that guarantees recoverability.

When a user issues a COMMIT, LGWR puts a commit record in the redo log buffer and flushes the entire buffer to disk. The so called "fast commit" mechanism. Oracle can record a successful commit even though the data blocks have not yet been written to disk.


allen_7
Frequent Advisor

Re: Why oracle LGWR process should write redo log file before DBW0 process flush buffer cache?

Data integration - benefit