0% found this document useful (0 votes)
64 views7 pages

Buffer Management Notes: Adapted From Prof Joe Hellerstein's Notes

The document summarizes key aspects of buffer management in a database management system (DBMS). When a page is requested that is not already in memory, the buffer manager must choose an existing frame to replace using a replacement policy like LRU. It tracks metadata like the pin count and dirty bit for each page. Maintaining pages in memory through buffering allows the DBMS to access data faster than reading directly from disk for each operation.

Uploaded by

Komal Jogi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views7 pages

Buffer Management Notes: Adapted From Prof Joe Hellerstein's Notes

The document summarizes key aspects of buffer management in a database management system (DBMS). When a page is requested that is not already in memory, the buffer manager must choose an existing frame to replace using a replacement policy like LRU. It tracks metadata like the pin count and dirty bit for each page. Maintaining pages in memory through buffering allows the DBMS to access data faster than reading directly from disk for each operation.

Uploaded by

Komal Jogi
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 7

Buffer Management Notes

Adapted from Prof Joe Hellerstein’s notes


http://db.cs.berkeley.edu/dbcourse/notes.html
Buffer Management in a DBMS
Page Requests from Higher Levels

BUFFER POOL

disk page

free frame

MAIN MEMORY

DISK choice of frame dictated


DB by replacement policy
• Data must be in RAM for DBMS to operate on it!
• Buffer Mgr hides the fact that not all data is in RAM
When a Page is Requested ...
• Buffer pool information table contains:
<frame#, pageid, pin_count, dirty>

• If requested page is not in pool:


– Choose a frame for replacement.
Only “un-pinned” pages are candidates!
– If frame is “dirty”, write it to disk
– Read requested page into chosen frame
• Pin the page and return its address.

If requests can be predicted (e.g., sequential scans)


pages can be pre-fetched several pages at a time!
More on Buffer Management

• Requestor of page must eventually unpin it, and indicate


whether page has been modified:
– dirty bit is used for this.
• Page in pool may be requested many times,
– a pin count is used.
– To pin a page, pin_count++
– A page is a candidate for replacement iff pin count == 0
(“unpinned”)
• CC & recovery may entail additional I/O when a frame is
chosen for replacement.
– Write-Ahead Log protocol; more later!
Buffer Replacement Policy

• Frame is chosen for replacement by a


replacement policy:
– Least-recently-used (LRU)
– Most-recently-used (MRU)
• Also called toss-immediate
– Clock
• Policy can have big impact on # of I/O’s;
depends on the access pattern.
LRU Replacement Policy
• Least Recently Used (LRU)
– for each page in buffer pool, keep track of time when
last unpinned
– replace the frame which has the oldest (earliest) time
– very common policy: intuitive and simple
• Works well for repeated accesses to popular pages
• Problems?
• Problem: Sequential flooding
– LRU + repeated sequential scans.
– # buffer frames < # pages in file means each page
request causes an I/O.
– Idea: MRU better in this scenario? We’ll see in HW1!
A(1)
“Clock” Replacement Policy
D(1) B(p)
• An approximation of LRU
• Arrange frames into a cycle, store one C(1)
reference bit per frame
– Can think of this as the 2nd chance bit
• When pin count reduces to 0, turn on ref. bit
• When replacement necessary
do for each page in cycle {
if (pincount == 0 && ref bit is on)
turn off ref bit;
else if (pincount == 0 && ref bit is off)
choose this page for replacement;
} until a page is chosen; Questions:
How like LRU?
Problems?

You might also like