Learn Labs
4. Storage and Retrieval

4.13 Self-test

Self-test20 questions

—/20
  1. Why is db_get O(n) but db_set fast, and what single data structure fixes reads without changing the write path?

  2. Name the four problems with an in-memory hash index over a log. Which one does an SSTable's sparse index solve, and how?

  3. Why can't you simply append to an SSTable? Describe the memtable→segment→compaction cycle that resolves this.

  4. What exactly does a Bloom filter guarantee, and what does it not guarantee? Why is a false positive harmless in an LSM engine?

  5. You have a read-heavy workload with a large key space. Size-tiered or leveled compaction, and why?

  6. A B-tree page split crashes halfway. What two forms of corruption can result, and what mechanism prevents them?

  7. Why do SSDs — with no moving parts — still prefer sequential writes? Trace the answer through page size, block size, and GC.

  8. Define write amplification. Give one reason LSM is usually lower and one reason a B-tree can be very high for a small update.

  9. Why can taking a consistent snapshot be nearly free in an LSM engine and expensive in a B-tree?

  10. What's the difference between a clustered index, a heap file, and a covering index? When does updating a heap-file row force every index to be rewritten?

  11. Why are in-memory databases fast? (The answer is not "they avoid disk reads.")

  12. Why does sorting rows improve compression most for the first sort key and barely at all for the fourth?

  13. Why must a column store sort whole rows, never individual columns?

  14. Explain how WHERE product_sk = 30 AND store_sk = 3 is answered with two bitmaps. What property of columnar storage makes the bitwise AND valid?

  15. Contrast query compilation with vectorized processing. Name two CPU characteristics both exploit.

  16. Give one query a data cube answers instantly and one it fundamentally cannot answer. Why?

  17. Why can a concatenated (latitude, longitude) index not answer a map-viewport query? Name two index types that can.

  18. Reframe full-text search as a multidimensional query. What is a postings list, and why can it be a bitmap?

  19. Why don't R-trees work for 1536-dimensional embeddings? Compare flat, IVF, and HNSW on accuracy and speed.

  20. Design question

    you're storing 10 TB of IoT sensor readings, written 500k rows/sec, queried as "average value per sensor per hour for the last 7 days." Choose a storage engine, a sort key, and a compaction/partition strategy — and justify each against the trade-offs in this chapter.