RelationalDBDesign RelationalDBDesign

Database Architecture   «Prev 

Oracle does not write all changes immediately

  1. What is the need for redo log files?
  2. Why does not Oracle just write all changes to disk immediately?
  3. How can writing the data twice, once to the redo logs and once to the datafiles, be efficient?
The answer is that the changes are not written to the datafiles one at a time. Oracle maintains a memory area called the database buffer cache[1], that contains the most recently accessed database blocks. A large database buffer cache increases the odds that any given block will already be in memory needed, reducing the need for disk I/O. When a program issues an UPDATE statement, Oracle makes the change in memory because that's much faster than writing the same data back to disk.
Your program can then continue to do other work. Your changes are eventually written to disk, because Oracle maintains a background process that continuously writes updated blocks back to disk. This use of a memory buffer keeps performance reasonable when a large number of users are updating the database all at once. The overhead involved in writing changes to the redo log is not as bad as you would think. First, the redo log is written sequentially. There are never any locking issues to worry about. Second, only the changes to a block are written, not the entire block itself.
[1] database buffer cache: The purpose of the database buffer cache: is to hold as many data blocks in memory as possible in order to minimize the number of reads that an instance needs to perform.