I am wondering why the Oracle server writes to the redo log anyway? Why can it first put changed blocks in some memory buffer and then when the transaction commits or rollbacks write them to disk or from the rollback segment respectively? They say redo logs are for recovery, but if blocks are written directly to disk when commited transactions what is the purpose of recovery?
Clearly I am missing something crucial...HELP...
Because oracle is professional database, and u can restore it "till last transaction"
even if u lost all datafiles.
Writing to logs allows old versions of data files to be used in place of current files in cases of media failure, then the "outdated" files have the appropriate transactions written to them from the logs. Without this mechanism, there would be no way to recover to any time more recent than the most recent backup.
Logs are written to sequentially and only changed data is written. Conversely, writes to data files are random access and are written in DB_BLOCK_SIZE increments (2-8k). Subsequently, the data file writes are performed asynchronously. This is done because the sequential small write to the log with subsequent asyncronous data file write is MUCH faster than writing to data files synchronously during transactions.
Oracle DBA and Developer
as kmesser said .. sequential write to the logs are much faster than to the data files which is not sequential. thats perfect.
can u imagine if oracle tries to write at each and every commit or rollback ,as u said, how badly it will perform. everytime it has to look for free extents, format the blocks, in some cases allocate the extents and so many other things. thats the reason log file come into picture. instead it just sequentilly write the blocks into logs. and then bulk insert into data file.
so in case of crash log files are used for recovery.
8i OCP DBA
This is not an Oracle problem, nor an Oracle invention. Every single modern RDBMS technology take advantage of speeding and recovery using logs...
I agree completely to sjadhavdba. Oracle does something called as
"Fast Commit". It means that Oracle, does not writes into the datafiles as and when
an Commit statement is issued especially due to 2 reasons:
1. More amount of IO reduces performance.
2. In the redo log files, oracle just writes minimal information required to
redo all the amount of work. More over writes in redo log is sequential, which
may not be the case in directly writing to the files.
Not only RDBMS uses this, UNIX Journal Filesystem works pretty similar
Click Here to Expand Forum to Full Width