7 Buffer Pool Management

Week 7: March 13 - 26, 2022

  • COWS Section 9.4

7.1 What is the Buffer Pool Manager?

The buffer pool manager provides the illusion that the disk pages requested by upper layers of the DBMS are in memory. A lot of systems engineering is about deception.

If you took operating systems, you have seen this theme many times: For example, the OS deceives applications that they have full 64-bit address spaces when they don’t and it does this by adding a level of indirection and address translation: the virtual memory management unit.

In the case of the DBMS buffer manager, the deception is making it seem that all the pages are in and can fit in memory! It does this by providing translation services: it translates the page ID requested to its location in memory once it is loaded; it makes sure to some degree that the pages in memory and on disk are in sync (by writing back dirty pages to disk — more on this much later in the course); and it works seamlessly behind the scenes quickly shuffling in and out pages from disk to memory because memory isn’t large enough to hold all the pages that the many queries executing within a DBMS may request.

The buffer pool is a large array of frames allocated on server start-up. The meta-data that keeps track of where different pages are (i.e. which frames) is maintained in a page-table. It provides the translation and tracks other information that may be important when deciding which pages to evict from the buffer pool, when new page requests are made and there is no longer any space in the buffer. The page table also keeps track of which pages are dirty i.e. the copy in memory may be different from the copy on disk because of updates that occurred on the page and which pages are pinned i.e. currently in use by one or more transactions.

Page requestors unpin pages immediately after use to allow the buffer pool manager to evict them if it needs the space.

7.2 Page Replacement Policies

We will look at three basic policies (LRU, CLOCK, MRU), but there are more sophisticated ones:

7.2.1 LRU

Buffer & Access Pattern Configuration
Buffer size: # of pages to read: Access Pattern:
Repeat? Long running transactions?
Access Reference Stream
The Buffer Pool
Buffer/Disk Statistics
Cache Hits 0
Cache Misses 0
Disk Writes 0

7.2.2 Clock - Approximate LRU

Buffer & Access Pattern Configuration
Buffer size: # of pages to read: Access Pattern:
Repeat? Long running transactions?
Access Reference Stream
The Buffer Pool
Buffer/Disk Statistics
Cache Hits 0
Cache Misses 0
Disk Writes 0

7.2.3 MRU

Buffer & Access Pattern Configuration
Buffer size: # of pages to read: Access Pattern:
Repeat? Long running transactions?
Access Reference Stream
The Buffer Pool
Buffer/Disk Statistics
Cache Hits 0
Cache Misses 0
Disk Writes 0

7.3 Policy Optimizations & OS Caches