Review: (R&G Chapter 9) - Aren't Databases Great? - Relational Model - SQL
Review: (R&G Chapter 9) - Aren't Databases Great? - Relational Model - SQL
Review: (R&G Chapter 9) - Aren't Databases Great? - Relational Model - SQL
Relational Operators
Buffer Management
Disk Space Management
DB
Quick Review
Andromeda
Tape /Optical
Robot
10 6 Disk
100
Sacramento
Memory
2,000 Years
Pluto
2 Years
1.5 hr
10 On Board Cache
2 On Chip Cache
1ns Registers
Components of a Disk
Disk head
Tracks
Arm movement
Arm assembly
Disks
Platters
Thought experiment
What is a good disk page size?
8K?
32K?
1Meg?
Why?
Context
Query Optimization
and Execution
Relational Operators
allocate/de-allocate a page
read/write a page
Buffer Management
Disk Space Management
DB
BUFFER POOL
disk page
free frame
MAIN MEMORY
DISK
DB
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?
A(1)
B(p)
An approximation of LRU
C(1)
Arrange frames into a cycle, store one reference bit
per frame
Can think of this as the 2nd chance bit
Context
Query Optimization
and Execution
Relational Operators
Files and Access Methods
Buffer Management
Disk Space Management
DB
Files of Records
Header
Page
Data
Page
Data
Page
Data
Page
Data
Page 2
Full Pages
Header
Page
Data
Page
Data
Page
Data
Page
Pages with
Free Space
Data
Page N
DIRECTORY
F1
F2
F3
F4
L1
L2
L3
L4
Address = B+L1+L2
F2
F3
Slot 1
Slot 2
F4
...
$
Slot N
F2
Slot 1
Slot 2
F3
Free
Space
Slot M
F4
N
PACKED
1 . . . 0 1 1M
number
of records
M ...
3 2 1
UNPACKED, BITMAP
number
of slots
...
Slot N
System Catalogs
For each relation:
Page i
Rid = (i,2)
Rid = (i,1)
...
16
2
24
N
1 # slots
SLOT DIRECTORY
Pointer
to start
of free
space
rel_name
Attribute_Cat
Attribute_Cat
Attribute_Cat
Attribute_Cat
Students
Students
Students
Students
Students
Faculty
Faculty
Faculty
pg_attribute
type
position
string
1
string
2
string
3
integer
4
string
1
string
2
string
3
integer
4
real
5
string
1
string
2
real
3
Summary
Summary (Contd.)
DBMS vs. OS File Support
DBMS needs features not found in many OSs, e.g.,
forcing a page to disk, controlling the order of
page writes to disk, files spanning disks, ability to
control pre-fetching and page replacement policy
based on predictable access patterns, etc.
Summary (Contd.)