Brendan Ang

Search

Search IconIcon to open search

Buffer Pools

Last updated Nov 8, 2022 Edit Source

# Buffer Pools

An area of memory used as a buffer between the disk and the database system

# Page table

A page table is used to keep track of the pages loaded in the buffer pool. This helps the system to determine if the page is already in buffer without having to go to the disk.

# Buffer Manager

Used to control the memory in the buffer pool and provide the following features:

# Prefetching

While the current page is being processed, we can prefetch the next required pages to be accessed based on a query plan. This reduces total I/O time as operations are done in parallel.

# Scan sharing

If a query starts a scan and if there is one already doing this, it would attach to that query’s cursor. Once that current query is complete, the new query can continue to scan those pages that were initially skipped.

# Buffer Replacement Policies

Similar to Cache Replacement Policies. Page Replacement Policies

# Practice Problems

Process flow:

  1. Fetch block 1
  2. Process block 1 and Fetch block 2
  3. Process block 2 and Fetch block 3
  4. Process block 3 a. Total time is 4P; only 4 cycles needed b. R + P + 2R = 3R + P c. R + P + 2P = 3P + R

If no pre-fetching: 3(R+P) = 3R + 3P

ReferenceLRUOptimal
5ABCDEABCDE
6ABCEDABCDE
7BCEDF/AABCDF/E
8BCEFDABCDF
9CEFDG/BABCDG/F
10CEFGDABCDG
11EFGDH/CABCDH/G
12EFGHDABCDH
13FGHDC/EABCDH
The LRU is suboptimal in this case because it chooses to replace useful pages like B/C which are needed later. A more optimal strategy is to choose pages for replacement based on the corresponding level of the page in the B-Tree.