databasedistributed-databaseyugabytedb

Working of compactions work in YugaByte DB


What flavors of compaction (e.g., size-tier/level compactions) are supported? And what parameters control the behavior of compactions?


Solution

  • YugabyteDB Compactions Overview:

    --rocksdb_universal_compaction_min_merge_width (default 4)
    --rocksdb_universal_compaction_size_ratio (default 20)
    

    By default, compactions run only if there are at least 4 eligible files and their running total (summation of size of files considered so far) is within 20% of the next file in consideration to be included into the same compaction.

    --rocksdb_max_background_compactions (e.g, 4)
    --rocksdb_compact_flush_rate_limit_bytes_per_sec (e.g., 268435456)
    

    • Using yb-admin tool, YugabyteDB also allows manual compactions to be externally triggered on a table. This can be useful for cases when new data is not coming into the system for a table anymore, but user wants reclaim disk space due to overwrites/deletes that have already happened or due to TTL expiry.