{
  "slug": "leveled-compaction",
  "term": "Leveled compaction",
  "aliases": [
    "Level compaction"
  ],
  "definition": "Leveled compaction organizes sorted data into levels with size targets and merges selected data with overlapping key ranges in a destination level.",
  "note": "In RocksDB, each nonzero level is one sorted run partitioned across SST files with nonoverlapping key ranges within that level; L0 can contain multiple overlapping runs. One run is not necessarily one file. [rocks-levels] Compared with tiering, leveling usually trades more rewriting for fewer candidate runs and lower space overhead, but workload skew and file-selection policy affect that trade-off. RocksDB's L0 makes its Level policy a tiered-plus-leveled hybrid. [rocks-compaction]",
  "related": [
    "lsm-tree",
    "compaction",
    "tiered-compaction",
    "read-amplification",
    "space-amplification"
  ],
  "citations": [
    {
      "id": "rocks-levels",
      "title": "RocksDB project. Leveled Compaction: sorted runs and the L0 exception.",
      "url": "https://github.com/facebook/rocksdb/wiki/Leveled-Compaction",
      "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": "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"
}
