Database Indexing hard
In LSM compaction strategies, 'Universal' (Tiered) compaction prioritizes what over 'Leveled' compaction?
- A Write Throughput. It significantly reduces write amplification by delaying the merging of files, though this leads to increased read latency.
- B Point-Lookup Performance. It ensures that every record is stored in exactly one physical file location to eliminate the need for cross-level merging.
- C Disk Space Efficiency. It utilizes aggressive compaction algorithms to ensure that the total disk usage never exceeds the actual live data size.
- D Memory Resident Caching. It automatically prioritizes the most frequently accessed data blocks for inclusion in the high-speed operating system page cache.
Answer: A. Write Throughput. It significantly reduces write amplification by delaying the merging of files, though this leads to increased read latency.
LSM compaction usually follows two patterns: 'Leveled' and 'Tiered' (Universal). Leveled compaction (like standard RocksDB) keeps each level very small and sorted, ensuring fast reads but causing high Write Amplification as files are constantly rewritten. Tiered compaction allows many overlapping files to exist at each level. This means you write much less often (lower Write Amp), but searching for a key is slower because you might have to check many different files (higher Read Amp).
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- Z-Order Curves (Geohashing) map 2D data to 1D strings for indexing. What is their primary weakness?
- In-Memory databases (Hyper, HANA) often favor Adaptive Radix Trees (ART). Why?
- Log-Structured Merge (LSM) Trees (RocksDB, Cassandra) optimize for Write Throughput. How does their disk IO pattern differ from B-Trees?
- In LSM trees, what is 'Space Amplification'?
- Why is it generally ineffective to index a 'Low Cardinality' column like `Gender` ('Male'/'Female')?
- You have a composite index on `(Lastname, Firstname)`. Which query can efficiently use this index?