Sunday, October 28, 2012

Database Buffer Cache

The database buffer cache consists of the memory buffers that Oracle uses to hold the data read by the server process from datafiles on disk in response to user requests. When the users modify data, those changes are made in the database buffer cache. Thus the buffer cache contains both the original blocks by physical read from disk and the changed blocks that have to be written back to disk.
Note. Logical read, the hot block which is in Buffer Cache, is much faster than Physical read.

Database buffer cache can be group into three components:
Free buffers: These are buffers that contains no data, and, thus, the database can use them to hold new data it reads from disk.
Dirty buffers: These contain data that was read from disk and then modified, but hasn't yet been written to the datafiles on disk.
Pinned buffers: These are data buffers that are currently in active use by user sessions.

When a user process requests data, Oracle will first check whether the data is already available in the buffer cache. If it is, the server process will read the data from the memory directly  and send it to the user. If the data is not found in the buffer cache, the server process will read the relevant data from the datafiles on disk and cache it in the database buffer cache.If the server process can’t find a free buffer after searching through a threshold number of buffers, it asks the database writer process to write some of the dirty buffers to disk for time being until the user fire commit for that transaction , thus freeing up for writing the new data it wants to read into the buffer cache.

No comments:

Post a Comment