Storage Architecture#
Presentation is on: Storage Slides ↗
Disk Space Management#
- Disk Space Manager: Manages contiguous pages with allocation locks.
Usable Block Tracking & Buffer Policies#
- Block List Maintenance: Tracks free and allocated pages.
- Replacement Policies:
- LRU (Least Recently Used)
- Clock (1-N hand pointer tracking reference bits)
- Sequential-Flooding (edge case vulnerability in sequential scans)
- FIFO (First-In, First-Out)
- MRU (Most Recently Used)
Buffer Management: DBMS vs. OS#
- DBMS vs. OS Virtual Memory: While OS provides virtual memory, DBMS requires precise control over page access prediction and synchronous page-to-disk write sequencing.
- Access Prediction: High-level query execution plans (e.g., sequential scans, index lookups) provide known page access patterns.
- Prefetching: Proactively loading anticipated pages into memory in large blocks (like 32 X 4KB, configurable) while CPU executes other tasks, minimizing I/O wait times.
- Write-Ahead Logging (WAL): DBMS must ensure buffer pages are logged and managed independently of OS paging to enforce durability rules.
- File Indexing: Indexes reference external data records (e.g., B+ trees storing search keys pointing to data nodes).
Accessing Record Files#
- File Organization: DBMS treats a file as a collection of records spanning multiple pages.
Heap File Implementation#
- Unordered Storage: Guarantees retrieval of all records via full scan; pages maintain uniform sizes.
- Core Operations: Create/delete files, insert records, delete by Record ID (RID), fetch by RID, and scan all records. RID resolves to <page id,slot number>.
- Page Tracking Structures:
- Doubly Linked Lists: Header page pointing to full and free page lists.
- Directory of Pages: Maintained by the DBMS to track content pages and free space bits/counters for variable-length records.
Page and Record Formats#
Page Formats#
- Slot-Based Page Layout: Pages are structured as a group of slots where each slot points to a record.
- RID Structure: <Page ID, Slot Number>.
- Fixed-Length Records:
- Stored in N fixed slots. Deletion moves the last record into the released slot or updates a bit array.
- Variable-Length Records:
- Slot Directory: <Record Offset,Record Length>. Offset set to -1 if deleted. RID remains stable even when records move within the page.
- Space Management: Free space is maintained contiguously; records are shifted to compact space as needed.
Record Formats#
- System Catalog: Stores metadata (length, data types).
- Fixed-Length Records: Contiguous storage layout where offsets are calculated directly.
- Variable-Length Records: Uses separator symbols and an offset/displacement array at the beginning of the record, with the end address storing null indicators. Allows direct access to fields and efficient support for null values.
Review Questions & Concepts#
- Primary vs. Secondary vs. Tertiary Storage: Differences in volatility, speed, and cost. Permanent storage is critical for DBMS to ensure persistent data survival across system restarts.
- Magnetic Disks in DBMS: Advantages over main memory (non-volatility, cost-effectiveness for large datasets) and magnetic tape (direct random access vs. sequential access). Disadvantages include mechanical seek latencies.
- Disk Blocks and Pages: Layout, arrangement, and access time components (seek time, rotational latency, transfer time).
- Disk Geometry Optimization: Careful page positioning for sequential reading to minimize seek and rotational delays.
- RAID Systems: Performance and reliability trade-offs across RAID levels (0, 1, 10, 2, 3, 4, 5, 6). Impact of data striping and parity.
- Disk Space Manager: Role of DBMS disk space manager vs. OS delegation.
- Buffer Management: Frames, file pages, disk blocks, buffer pool, page pin counts, dirty flags, and replacement policies (preventing sequential flooding).
- Prefetching & WAL: Predictive page access, asynchronous I/O, prefetch blocks, and Write-Ahead Logging requirements.
- File and Record Abstraction: Slot-based page organization, fixed vs. variable-length record layouts, slot directories, displacement arrays, and direct field access supporting null values.