Javatpoint Logo
Javatpoint Logo

Buffer Replacement Strategies

Buffer replacement is a method of replacing existing blocks in the buffer with the new block. By doing so, it helps to reduce the number of disk access.

The buffer manager uses the following strategies for Buffer Replacements:

Least Recently Used (LRU) Strategy

According to LRU, the data or process which has the lowest score in its recent use is replaced with the new process or data. In block-replacement strategy, if there is a need to replace an existing block, the least recently referenced block gets replaced. However, the replacement scheme of a database system is different from the operating system. An operating system depends on the past for predicting the future. But, a database system is capable of predicting the future plan accurately. Generally, a user needs to follow various steps for making a block request to the database system. However, these steps enable the database system to determine the requested block in advance.

Toss-immediate Strategy

According to this strategy, when the space occupied by a specific block is freed, the buffer manager should get instructed before the processing of the final result. It will help the database system to know that space is going to be vacant, and a new block can be allocated to that place. This type of block-replacement strategy is known as the Toss-immediate strategy.

For example, consider two relations R1 and R2 stored in separate files. If R1 once processed is not needed again. So, the processing of the block containing R1 is completed, and the block is no longer required in the main memory. Even it has been recently used. Finally, the buffer manager gets the information, and it passes the report to the database system for further processing.

Most Recently Used (MRU) Strategy

MRU follows the opposite strategy of LRU. According to MRU, the data or process which has the highest score in recent use gets replaced with the new data or process. In block-replacement strategy, the block which is recently used gets replaced with the new block. Such type of strategy of Buffer-replacement is known as Most Recently Used strategy.

As a result, a database system picks and follows a suitable strategy based on different scenarios. But, it is seen that large database systems at most uses LRU techniques even though it may have some faults too. Time is also an influencing factor in choosing the appropriate strategy. As sometimes, a database system may get concurrent user requests, so to preserve the data consistency, it may need to delay some requests. During this, if the buffer manager gets to know the information of the requested blocks which are delayed, then it may use that information for altering its strategies. However, a buffer manager can retain the request of the non-delayed blocks with the delayed blocks.


Next TopicDatabase Buffer




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA