Pages

Search

Monday, November 17, 2008

Oracle - Moving data changes from memory to disk

Memory is entirely different to disk. Memory is what server process uses like fetching data from disk to buffer cache (memory) or memory is also used to perform actions made by DML statements in oracle server instead of directly posting on to the main disk.

Once DML statements are executed there is no further need to fetch data from disk to buffer cache or cursor as select statement.
When these DML statements are executed which does data manipulation upon the rows or blocks in buffer which are no longer identical with the one in disk are said to be “dirty” blocks. This does not mean that these blocks are erased as they contain the actual data change values which are to be posted or saved to the disk. Also the redo log buffer is updated with the data changes made by the DML statement. By making the data changes in memory, Oracle is able to achieve excellence as it takes less time to do actions on memory than on disk directly.
Mainly, it is not required to hold or make user in wait state till the data change is updated on to disk.

This process of saving data changes from buffer cache (memory) to disk is done asynchronously and said to as one among the back ground processes of Oracle.
There are 2 back ground processes that are part of this synchronous action.

1) DBW0.
2) LGWR.

These write data changes from buffer cache and redo log buffer to disk. Since these processes are asynchronous, they occur some time after the user actually made the changes.

DBW0:
This is called as database writer process, this process identifies the dirty blocks in buffer cache and updates them to disk. There are recently many versions of this released by Oracle. There are several instants that fire this process.

1) When server process need to make room in buffer cache to fetch data from disk for user process.
2) When DBW0 is told by LGWR (log writer process) to write data to disk.
3) Every 3 seconds due to time out.
4) The number of dirty buffers reaches maximum extent or threshold value.
The event when LGWR asks DBW0 to write data to disk is called check point.
DBW0 indicates 0th process, there can be from 0 to 9 digits which means there can be 10 data base writer processes for a single Oracle instance.


LGWR:

This back ground process is called log writer process, this writes redo log entries from redo log buffer in memory to online redo log files on disk. This also has specialized functions related to management of redo information.
As said LGWR asks DBW0 to write dirty blocks to disk.
There are instants when this LGWR is fired or a asked to perform actions.

1) When a transaction is committed.
2) When redo log buffer is 1/3 rd full.
3) When there is more than a mega byte of changes recorded in the redo log buffer.
4) Before DBW0 writes dirty blocks from buffered cache to disk files.

No comments:

Post a Comment