CS3223 - Storage 1
Disks, Memories & Buffer Management
“The two offices of memory are collection and distribution.”
- Samuel Johnson
Disks, Memories & Buffer Management The two offices of memory - - PowerPoint PPT Presentation
Disks, Memories & Buffer Management The two offices of memory are collection and distribution. - Samuel Johnson CS3223 - Storage 1 What does a DBMS Store? Relations Actual data Indexes Data structures to speed up
CS3223 - Storage 1
“The two offices of memory are collection and distribution.”
CS3223 - Storage 2
– Primary memory: registers, static RAM (caches), dynamic RAM (physical memory)
– Secondary memory: magnetic disks (HDD), solid state disks (SSD)
– Tertiary memory: optical disks, tapes, jukebox
– Capacity – Cost – Access speed – Volatile vs non-volatile
CS3223 - Storage 3
CS3223 - Storage 4
CS3223 - Storage 5
CS3223 - Storage 6
– Typical page size is 4KB – 1MB – Typical block size is 1MB – 64MB
– Therefore, relative placement of pages on disk has major impact on DBMS performance!
CS3223 - Storage 7
The platters spin (say, 120rps) The arm assembly is moved in or
the head make a (imaginary) cylinder Only one head reads/writes at any one time Block size is a multiple of sector size (which is fixed)
CS3223 - Storage 8
CS3223 - Storage 9
CS3223 - Storage 10
CS3223 - Storage 11
average seek time 18 ms track-to-track seek time 5 ms average rotational delay 8.3 ms maximum transfer rate 16.7 ms/track bytes/sector 512 sectors/track 40 tracks/cylinder 11 tracks/surface 1,331
CS3223 - Storage 12
CS3223 - Storage 13
CS3223 - Storage 14
– <$1 will buy you 1 GB of RAM
– “Big-Data” phenomenon
– We want data to be saved between runs
– Larger memory means higher chances of data corruption
– In a typical query execution in an in-memory database, 59% of the overall energy is spent in main memory – Furthermore, there are inherent physical limitations related to leakage current and voltage scaling that prevent DRAM from further scaling
– DBMS is running more than one applications, and managing more than one
CS3223 - Storage 15
– disk space is effectively utilized – files can be quickly accessed
– How is the free space in a disk managed?
link lists
– How is the free space allocated to files?
– How is the allocated space managed?
CS3223 - Storage 16
– if a block is free, its corresponding bit is 0 – if a block is allocated, its corresponding bit is 1
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
CS3223 - Storage 17
– look up FSLH – follow the pointers – reset the FSLH 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
grows in size
CS3223 - Storage 18
CS3223 - Storage 19
– Database “catalog”
Header Page Data Page Data Page Data Page Data Page Data Page Data Page Pages with Free Space Full/Used Pages
CS3223 - Storage 20
page.
is just one alternative
– Much smaller than linked list of all HF pages! Data Page 1 Data Page 2 Data Page N Header Page
DIRECTORY
CS3223 - Storage 21
DB
MAIN MEMORY DISK disk page free frame Page Requests from Higher Levels BUFFER POOL choice of frame dictated by replacement policy
DBMS to operate on it!
allocated for DBMS
into pages called frames
pairs is maintained
values: pin count and dirty flag
CS3223 - Storage 22
– If no free frames available
– What are such frames?? How to choose?
– Read requested page into chosen frame
– a page is requested/shared by multiple transactions? – no page can be replaced? (when will this happen?)
CS3223 - Storage 23
CS3223 - Storage 24
CS3223 - Storage 25
same for all records in a file; stored in system catalogs
Base address (B) L1 L2 L3 L4 F1 F2 F3 F4 Address = B+L1+L2
4 $ $ $ $ Field Count Fields Delimited by Special Symbols F1 F2 F3 F4
CS3223 - Storage 26
can be shifted around within the page without changing record id.
Free Space
M 1 . . . M ... 3 2 1 UNPACKED, BITMAP Slot 1 Slot 2 Slot N Slot M 1 1 number
CS3223 - Storage 27
Page i 20 bytes 16 bytes 24 bytes Rid = (i,N) Rid = (i,2) Rid = (i,1)
Pointer to start
space
SLOT DIRECTORY
N . . . 2 1 20 16 24
N # slots
28
– page reference patterns are predictable – pages can be pinned, and forced to disk – can prefetch multiple pages in advance
CS3223 - Storage
File of records Disk pages Disk storage Main memory