Skip to content

Compaction

Spicy — senior dev territoryDatabase

ELI5 — The Vibe Check

Compaction is the database's housekeeping process that merges and cleans up files on disk. In LSM trees, it combines multiple sorted files into bigger sorted files and throws away deleted data. Without compaction, reads get slower and disk usage balloons. It's like periodically organizing your desk instead of just adding more piles.

Real Talk

Compaction is the background process in LSM-tree databases that merges multiple sorted files (SSTables) to reduce read amplification, reclaim space from deleted/overwritten data, and maintain query performance. Compaction strategies include size-tiered (merge similarly-sized files), leveled (maintain size-bounded levels), and FIFO (time-based expiration). Compaction consumes I/O and CPU, requiring careful tuning.

When You'll Hear This

"Compaction spikes caused latency jitter until we tuned the strategy." / "Leveled compaction gives better read performance but uses more I/O."

Made with passive-aggressive love by manoga.digital. Powered by Claude.