In our previous section, we learned about various types of data storage. But, the goal of a database system is that a minimum number of transfers should take place between the disk and memory. To do so, it can reduce the number of disk accesses by keeping as many blocks in main memory. So, when the user wants to store the data, it can directly search in the main memory, and there will be no requirement of accessing the disk. However, it is difficult to keep so many blocks in main memory; we need to manage the allocation of the space available in the main memory for the storage of blocks.
A database buffer is a temporary storage area in the main memory. It allows storing the data temporarily when moving from one place to another. A database buffer stores a copy of disk blocks. But, the version of block copies on the disk may be older than the version in the buffer.
To manage memory efficiently and improve database performance, the buffer manager uses several techniques for handling data blocks in memory and on disk.
If no space is left in the buffer, it is required to remove an existing block from the buffer before allocating the new one. The various operating system uses the LRU (least recently used) scheme. In LRU, the block that was least recently used is removed from the buffer and written back to the disk. Such type of replacement strategy is known as Buffer Replacement Strategy.
If the user wants to recover any database system from the crashes, it is essential to restrict the time when a block is written back to the disk. In fact, most recovery systems do not allow the blocks to be written on the disk if the block updation being in progress. Such types of blocks that are not allowed to be written on the disk are known as pinned blocks. Luckily, many operating systems do not support the pinned blocks.
In some cases, it becomes necessary to write the block back to the disk even though the space occupied by the block in the buffer is not required. When such type of write is required, it is known as the forced output of a block. It is because sometimes the data stored on the buffer may get lost in some system crashes, but the data stored on the disk usually does not get affected due to any disk crash.
We request you to subscribe our newsletter for upcoming updates.