{
  "slug": "compaction",
  "term": "LSM compaction",
  "aliases": [
    "LSM-tree compaction"
  ],
  "definition": "LSM compaction reorganizes sorted storage components, commonly merging selected runs or SST files and removing obsolete entries when visibility rules permit.",
  "note": "Compaction is not compression: it changes the organization and retained versions of data, whereas compression changes their representation. A snapshot can keep an older version necessary. Background merges consume CPU and I/O even when foreground queries perform no writes. [rocks-overview] Some nonoverlapping files can move between levels without rewriting their contents, so compaction need not rewrite every selected byte. [rocks-compaction] A strategy specifies trigger, layout, granularity and data-movement policy, not just leveled versus tiered organization. [compaction-design]",
  "related": [
    "lsm-tree",
    "sstable",
    "leveled-compaction",
    "tiered-compaction",
    "database-write-amplification"
  ],
  "citations": [
    {
      "id": "rocks-overview",
      "title": "RocksDB project. Overview: multi-threaded compaction and snapshot visibility.",
      "url": "https://github.com/facebook/rocksdb/wiki/RocksDB-Overview",
      "accessed": "2026-10-14"
    },
    {
      "id": "rocks-compaction",
      "title": "RocksDB project. Compaction: leveled, tiered and hybrid policies.",
      "url": "https://github.com/facebook/rocksdb/wiki/Compaction",
      "accessed": "2026-10-14"
    },
    {
      "id": "compaction-design",
      "title": "Sarkar, Staratzis, Zhu and Athanassoulis. Constructing and Analyzing the LSM Compaction Design Space. PVLDB 14(11), 2216-2229 (2021), DOI: 10.14778/3476249.3476274; updated arXiv:2202.04522v2 (2022), sections 2-5.",
      "url": "https://arxiv.org/abs/2202.04522v2",
      "accessed": "2026-10-14"
    },
    {
      "id": "hesela",
      "title": "Hesela. Bloom filters: optimize the lookup, not each filter; compaction and measurement boundaries.",
      "url": "https://hesela.com/analyses/bloom-filters-lsm-read-cost/",
      "accessed": "2026-10-14"
    }
  ],
  "status": "shipping",
  "advantages": [],
  "limitations": [],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-10-14"
}
