Disk-oriented DBMS
- DB are stored as normal files on disk. OS doesn’t know about in file content.
- Most DBMS runs on top of other file systems (like ext4, etc.)
- Some DBMS stores single file (e.g. sqlite, duck), but most DBMS store as multiple files.
- Within the DB file there can be multiple pages
- each page start with a header
- there is a special structure (called directory) to store metadata about the pages
- in memory, there is buffer pool manager that controls which page to cache in memory
- ensures that the page will be available in memory until execution engine done using it
- need 2 kinds of control:
- spatial control: where to write pages on disk
- temporal control: when to pull and flush pages to memory
DB representation in files
components
…
- Storage manager: maintaining DB files
- some even schedule reads and writes to take advantage of locality
- organizes files as a collection of pages
- track reads and writes and
- available space, etc.
- doesn’t handle replication, etc. → ensure only unique copy of a page is stored
- DB pages:
- A page is a fixed-size block of data with unique ID (within any scope, DB, table, DBMS, etc.)
- This is different from hardware page
- a hardware page is the largest block of data that storage device can guarantee failsafe!
- read-heavy DB should have larger page (1MB+) to fetch multiple content at once
- write-heavy DB should have smaller page (around 4KB) because DB needs to flush to disk even when only little portion is changed in the page
- DB file organization:
- different DBMS stores pages in files in different ways:
- heap file organization
- tree file organization
- sequential/sorted file (ISAM)
- hashing file
- Heap file: unordered collection of pages with tuples stored in arbitrary order
- need additional metadata to track location of pages in files
- DBMS maintains special pages called page directory
- also additional metadata like remaining space, page type (data/metadata), etc.
DB page format
2 parts: header and data
Header
metadata about data part:
- page size
- checksum
- DBMS version
- compression scheme, …