Build Your Own Database
a day ago
- #key-value
- #database
- #LSM-tree
- Key-value databases store data using a key and retrieve it later with the same key.
- Persistent data storage can be achieved using files, but in-place updates and deletes are inefficient.
- Append-only files make records immutable, treating updates and deletes as new records appended to the file.
- Duplicate keys and growing file sizes are challenges with append-only files.
- Segments and compaction help manage file size by periodically merging and cleaning up old data.
- Indices improve search performance by storing record offsets, though they slow down writes.
- Sorted string tables (SSTs) enable efficient range queries by keeping data sorted by key.
- LSM (Log-Structured Merge) Trees combine in-memory sorted lists (memtables) with on-disk SSTs for fast key-value operations.
- LSM Trees are used in large-scale databases like LevelDB and DynamoDB, offering high performance at scale.