DIsk BFR
DIsk BFR
DIsk BFR
1.1
DBMS architecture
Database app
Query Optimization
and Execution
Relational Operators
These layers
Access Methods must consider
concurrency
Buffer Management control and
recovery
Disk Space Management
Student Records
stored on disk
1.2
Why Not Store It All in Main Memory?
1.3
The Storage Hierarchy
(secondary storage).
On-chip Cache
• Tapes for archive, maybe
(tertiary storage). On-Board Cache
SSD
1.5
Disks and Files
1.6
1.7
Anatomy of a Disk
1.8
1.9
Accessing a Disk Page
Time to access (read/write) a disk block:
seek time (moving arms to position disk head on track )
rotational delay (waiting for block to rotate under head)
transfer time (actually moving data to/from disk surface )
Seek time and rotational delay dominate.
Wait
Seek time varies from about 1 to 15msec (full stroke)
Rotational delay varies from 0 to 8msec (7200rpm)
Transfer rate is < 0.1msec per 8KB block
Key to lower I/O cost:
reduce seek/rotation delays! Hardware vs.
Transfer Transfer
software solutions?
Rotate
Also note: For shared disks most time spent waiting in
queue for access to arm/controller Rotate
Seek
Seek
1.10
Arranging Pages on Disk
1.11
From the DB Administrator’s View
1.13
Notes on Flash (SSD)
1.14
CPU Typical
Computer
... ...
M C
Secondary
Storage
1.15
Storage Pragmatics & Trends
1.16
Buffer Management in a DBMS
Page Requests from Higher Levels
BUFFER POOL
disk page
free frame
MAIN MEMORY
choice of frame dictated
DISK by replacement policy
DB
1.18
When a Page is Requested ...
If requested page IS in the pool:
Pin the page and return its address.
Else, if requested page IS NOT in the pool:
If a free frame exists, choose it, Else:
1.19
Buffer Control Blocks (BCBs):
<frame#, pageid, pin_count, dirty>
A page may be requested many times, so
• a pin count is used.
• To pin a page, pin_count++
• A page is a candidate for replacement iff pin_count
== 0 (“unpinned”)
Requestor of page must eventually unpin it.
• pin_count--
Must also indicate if page has been modified:
• dirty bit is used for this.
Q: Why is this important?
Q: How should BCB’s be organized?
1.20
Additional Buffer Mgr Notes
1.21
Buffer Replacement Policy
Frame is chosen for replacement by a
replacement policy:
Least-recently-used (LRU), MRU, Clock, etc.
1.22
LRU Replacement Policy
1.23
“Clock” Replacement Policy
A(1)
An approximation of LRU
D(1) B(p)
Arrange frames into a cycle, store one
reference bit per frame
C(1)
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;
1.24
Some issues with LRU
1.25
DBMS vs. OS File System
OS does disk space & buffer mgmt: why not let OS manage these tasks?
1.26