140 likes | 285 Views
CS 257 Database Systems Principles Assignment 2. Instructor: Student: Dr. T. Y. Lin Rajan Vyas (119). Buffer Management. What does a buffer manager do?. Central Task of making memory buffers available to processors is done with the help of buffer managers. In practice:
E N D
CS 257Database Systems PrinciplesAssignment 2 Instructor:Student: Dr. T. Y. Lin RajanVyas (119)
What does a buffer manager do? • Central Task of making memory buffers available to processors is done with the help of buffer managers. • In practice: • rarely allocated in advance • the value of M may vary depending on system conditions • Therefore, buffer manager is used to allow processes to get the memory they need, while minimizing the delay and unclassifiable requests.
Introduction • Buffer Manager manages the required memory for the process with minimum delay. Read/Write Buffers Request
Two types of architecture: • Buffer Manager controls main memory directly • Buffer Manager allocates buffer in Virtual Memory • In Each method, the Buffer Manager should limit the number of buffers in use which fit in the available main memory. • When Buffer Manager controls the main memory directly, it selects the buffer to empty by returning its content to disk. If it fails, it may simply be erased from main memory. • If all the buffers are really in use then very little useful works gets done.
Buffer-replacement strategies: • Critical choice the buffer manager has to make is when a buffer is needed for a newly requested block and the buffer pool is full then which block to throw out the buffer pool.
LRU (Least Recent Used) It makes buffer free from the block that has not been read or write for the longest time. • FIFO(First In First Out) It makes buffer free that has been occupied the longest and assigned to new request. • The “Clock” Algorithm 0 0 1 1 0 0 1 1
The Relationship Between Physical OperatorSelection and Buffer Management
The query optimizer will eventually select a set of physical operators that will be used to execute a given query. • the buffer manager may not be able to guarantee the availability of the buffers when the query is executed.
Other Algorithms and M buffers Other Algorithms also are impact by M and the buffer-replacement strategy. • Sort-based algorithm • If we use a sort-based algorithm for some operator, then it is possible to adapt to changes in M. • If Af shrinks, we can change the size of a sublist, • since the sort-based algorithms we discussed do not depend on the sublists being the same size. The major limitation is that as M shrinks, • we could be forced to create so many sublists that we cannot then • allocate a buffer for each sublist in the merging process.. • Hash-based algorithm If M shrinks, we can reduce the number of buckets, as long as the buckets still can fit in M buffers.
Hash Table • If the algorithm is hash-based, ive can reduce the number of buckets if • shrinks, as long as the buckets do not then become so large that they do • not fit in allotted main memory. However, unlike sort-based algorithms, • we cannot respond to changes in A1 while the algorithm runs. Rather, • once the number of buckets is chosen, it remains fixed throughout the first • pass, and if buffers become unavailable, the blocks belonging to some of • the buckets will have to be ST\-appedout.