A database buffer is a section in the main memory that is used for the temporary storage of data blocks while moving from one location to another. A copy of the disk blocks is kept in a database buffer. However, the data on the disk can have an older version than the one in the database buffer as the database buffer is the one that gets affected first by the changes. When necessary, we can write the data block back to the disk memory.
Consider the following points to understand the functioning of buffer management in DBMS:
The buffer manager applies the following techniques to provide the database system with the best possible service:
If there is no space for a new data block in the database buffer, an existing block must be removed from the buffer for the allocation of a new data block. Here, the Least Recently Used (LRU) technique is used by several operating systems. The least recently used data block is taken out of the buffer and sent back to the disk. The term Buffer Replacement Strategy refers to this kind of replacement technique.
When a user needs to restore any data block from a system crash or failure, it is crucial to limit the number of times a block is copied/written to the disk storage to preserve the data. The majority of the recovery systems forbid writing blocks to the disk while a data block update is taking place. Pinned Blocks are the data blocks that are restricted from being written back to the disk. It helps a database to have the capability to prevent writing data blocks while doing updates so that the correct data persists after all operations.
Sometimes we may have to copy/write back the changes made in the data blocks to the disk storage, even if the space that the data block takes up in the database buffer is not required for usage. This method is regarded as a Forced Output of Blocks. This method is used because system failure can cause data stored in the database buffer to be lost, and often disk memory is not affected by any type of system crash or failure.
To learn about File Organization in DBMS, visit the link: