Buffer Management ID: 102 CS257 Spring 2008 Instructor: Dr.Lin
Contents Buffer Management Architecture Buffer Management Strategies Relationship Between Physical Operator Selection and Buffer Management Algorithms Using More Than Two Passes
Buffer Management Buffers use to store needed data Numbers of buffers depend on system conditions Responsibility to allow processes to get the memory Minimizing the delay and unsatisfiable requests
Buffer Management Architecture Two Architectures: In real main-memory reserved for the database, or In virtual memory Many “main-memory” DBMS’s and “object- oriented” DBMS’s operate this way
Buffer Management Strategies Buffer-Replacement Strategies Least-Recently Used (LRU) First-In-First-Out (FIFO) The “Clock” Algorithm (“Second Chance”) System Control
Least-Recently Used (LRU) For each page in buffer pool, keep track of time when last read or write Replace the frame which has the oldest (earliest) time Very common policy: intuitive, simple and effective
First-In-First-Out (FIFO) Know the time the block was loaded into the buffer Less maintenance than LRU
The “Clock” Algorithm An approximation of LRU Arranged in a circle
Relationship Between Physical Operator Selection and Buffer Management Physical operators may ask: Can the algorithm adapt to changes value of M How does the buffer-replacement strategy used by the buffer manager impact the number of additional I/O ’ s that must be performed
Other Algorithms Sort-based algorithm Main-memory sorting LRU FIFO Hash-based algorithm
Algorithms Using Passes Largest relations Process relations of arbitrary size Both sort- and hash-based approaches
Multipass Sort-based Algorithms Suppose M buffers, relation R R fits in M blocks, read R into main memory R does not fit into main memory partition the blocks into M groups Merge M sorted sublists Read M sublists, each into one buffer
Multipass Hash-Based Algorithm Used for large relations Suppose we have M memory We hash relation R to M-1 buckets, and relation S to M-1 buckets (same hash function)
Multipass Hash-Based Algorithm (cont’d) For each bucket, we use another hash function to hash each bucket to smaller buckets (R and S use the same hash function) Recursive process, until each pair of partitions fit into memory