Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Simple dumb question

Re: Simple dumb question

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 1997/09/30
Message-ID: <34371aed.7698750@newshost>#1/1

On Tue, 30 Sep 1997 13:47:27 +0100, arpege <arpege_at_imaginet.fr> wrote:

>Why is Oracle server going faster because it writes to log files rather
>than to data files ? In fact, log files contain column data before and
>column data after . Why does the server not write just to data files ?
>
>Philipe (arpege_at_imaginet.fr)

(In oracle, log files only contain REDO - after images. UNDO - before images are stored in rollback segments in the database)

In a nutshell its because sequentail IO is much faster then random IO and data integrity is important...

Log files are written too sequentially and optimally are stored on their own device so that the disk heads are 'owned' by the lgwr process and not being moved around by others. Log files in Oracle are never read from, except during recovery when the database starts up, so the sequential writes are pretty fast and not bothered by other seeks on that device.

Data files are written to in a scattered manner. If you update 5 rows, that might generate 5k of changes that needs to be written to 5 completely different places on disk. Compound this by having 10's or 100's of users doing this and the disks would spend all of their time seeking to do the updates.

As for data integrity, lets say you update 5 rows, generating 5k of changes to 5 different database blocks. You decide to commit. If the database fails during your commit, some of the redo may be recorded but the successful commit was not recorded (so we have some redo that was written but never used). If we wrote directly to the datafiles and didn't have log files, then if the system failed while we were writing the 5 blocks (we wrote 3 and had 2 pending) when the system restarted we would have no way of recovering. We couldn't undo the blocks we wrote and we couldn't redo the 2 blocks we hadn't. We would have corrupt data.

There are many other reasons as well but the above 2 are probably the 2 biggest reasons databases use log files (IMO).

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Bethesda MD

http://govt.us.oracle.com/ -- downloadable utilities



Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Tue Sep 30 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US