Storage Engine Foundations Lab
Retrieval Prompts
- State the approximate latency gap between main memory, an SSD random read, and an HDD random seek, in rough orders of magnitude.
- Describe the layout of a slotted page, in one paragraph, without looking anything up.
- Explain what the buffer pool stores, and what the
pin_countanddirtyflags mean. - State the LRU replacement rule, and one reason it can go badly wrong.
- Explain why a record's RID must remain stable across in-page moves.
Compare and Distinguish
Separate these pairs clearly:
- random vs sequential I/O on an SSD
- heap file vs sorted file vs clustered B+-tree
- logical page read vs physical I/O
- slot entry vs record body
- dirty page vs pinned page
Common Mistake Check
For each statement, identify the error:
- "SSDs eliminate the random-vs-sequential distinction."
- "A full table scan on a cold database touches
Nrandom pages, whereNis the number of rows." - "When a row is deleted, the slot is reused immediately for the next insert."
- "A buffer pool hit is free."
- "LRU is the best replacement policy for any workload."
Mini Application
Do all four tasks for each scenario:
- list the physical actions the engine performs
- classify each action as sequential or random I/O
- estimate the number of page reads (use an
8 KBpage assumption) - name at least one optimization that would reduce cost
Scenarios:
SELECT COUNT(*) FROM logson a20 GBheap file, no indexes.SELECT * FROM users WHERE id = 17on a PK-clustered5 GBtable.INSERT INTO orders VALUES (...)whereordershas3secondary B+-tree indexes.DELETE FROM events WHERE ts < now() - interval '365 days'matching10^7rows.- Startup scan of the buffer pool for a freshly restarted engine (what is cold, what is warm).
Buffer Pool Simulation
For a 4-frame pool and the access sequence
A B C D E A B C F A B D E F A B C D,
compute the number of hits and misses under:
- FIFO
- LRU
- Clock (single reference bit)
Then write one sentence on why each result differs.
Evidence Check
This page is complete only if you can narrate in pages and I/Os what happens during a simple query on a cold database, before you reach for any index structure.