pub struct DbOptions {Show 27 fields
pub create_if_missing: bool,
pub error_if_exists: bool,
pub write_buffer_size: usize,
pub max_immutable_memtables: usize,
pub l0_compaction_trigger: usize,
pub target_file_size_base: u64,
pub max_bytes_for_level_base: u64,
pub max_bytes_for_level_multiplier: f64,
pub num_levels: usize,
pub block_size: usize,
pub block_restart_interval: usize,
pub bloom_bits_per_key: u32,
pub compression: CompressionType,
pub block_cache_capacity: u64,
pub max_open_files: u64,
pub l0_slowdown_trigger: usize,
pub l0_stop_trigger: usize,
pub rate_limiter_bytes_per_sec: u64,
pub prefix_len: usize,
pub compression_per_level: Vec<CompressionType>,
pub compaction_filter: Option<Arc<dyn CompactionFilter>>,
pub max_background_compactions: usize,
pub max_subcompactions: usize,
pub pin_l0_filter_and_index_blocks_in_cache: bool,
pub block_property_collectors: Vec<Arc<dyn Fn() -> Box<dyn BlockPropertyCollector> + Send + Sync>>,
pub lazy_delete_compaction_threshold: usize,
pub block_cache: Option<Arc<BlockCachePool>>,
}Expand description
Database-level options.
Fields§
§create_if_missing: boolCreate the database directory if it does not exist.
error_if_exists: boolReturn an error if the database already exists.
write_buffer_size: usizeSize of a single MemTable in bytes before it is frozen.
max_immutable_memtables: usizeCurrently unused compatibility option.
MemTable freezes are flushed synchronously by the write path, so there is no immutable-MemTable queue for this value to bound. The field remains accepted for configuration compatibility and may be implemented or removed in a future major release.
l0_compaction_trigger: usizeNumber of L0 files that triggers compaction.
target_file_size_base: u64Target size for SST files in bytes.
max_bytes_for_level_base: u64Max total size of L1 in bytes.
max_bytes_for_level_multiplier: f64Multiplier between levels.
num_levels: usizeMaximum number of levels (including L0).
block_size: usizeBlock size for SST data blocks.
block_restart_interval: usizeRestart interval for prefix compression in data blocks.
bloom_bits_per_key: u32Bits per key for bloom filter. 0 disables bloom filter.
compression: CompressionTypeCompression type for SST data blocks.
block_cache_capacity: u64Block cache capacity in bytes. 0 disables caching.
max_open_files: u64Maximum number of TableReader entries retained by the table cache. Live Versions and iterators can pin additional readers.
l0_slowdown_trigger: usizeNumber of L0 files that triggers write slowdown.
l0_stop_trigger: usizeNumber of L0 files that stops writes until compaction completes.
rate_limiter_bytes_per_sec: u64Optional rate limiter for compaction writes (bytes/sec). 0 = no limit.
prefix_len: usizeFixed prefix length for prefix bloom filter. 0 = disabled (default).
When set, each SST file stores a bloom filter of key prefixes,
allowing iter_with_prefix() to skip entire SST files.
compression_per_level: Vec<CompressionType>Per-level compression types. If empty, uses compression for all levels.
Index corresponds to level number (0 = L0, 1 = L1, etc.).
compaction_filter: Option<Arc<dyn CompactionFilter>>Optional compaction filter. Wrapped in Arc so it survives Clone
and is shared with background compaction threads.
max_background_compactions: usizeMaximum number of background compaction threads. Default: 1.
RocksDB equivalent: max_background_compactions / increase_parallelism.
max_subcompactions: usizeMaximum sub-compactions per compaction job. Default: 1 (no sub-compaction).
RocksDB equivalent: max_subcompactions.
When > 1, a single compaction is split into parallel sub-tasks by key range
using target-level file boundaries as split points. Effective only when the
target level has enough files to split on.
pin_l0_filter_and_index_blocks_in_cache: boolEagerly warm the index-entry cache and pin each newly-flushed L0
file’s first data block in the block cache (never evict). Default:
true. Unlike RocksDB’s option of the same name, index and filter
blocks are never stored in block_cache — they are always held as
direct TableReader fields regardless of this setting.
RocksDB equivalent (name only, not behavior): pin_l0_filter_and_index_blocks_in_cache.
block_property_collectors: Vec<Arc<dyn Fn() -> Box<dyn BlockPropertyCollector> + Send + Sync>>Factories for block property collectors. Each factory is called once per SST file build to produce a fresh collector instance.
lazy_delete_compaction_threshold: usizeWhen the number of keys registered via [DB::lazy_delete_batch]
reaches this threshold, a background sweep is automatically
scheduled: every populated level is force-rewritten through the
compaction filter so the registered keys are physically removed
even when no organic compaction is pending. Comparable in cost to
an explicit [DB::compact] over the whole store — and, unlike
compact(), each level’s rewrite holds the DB’s write-serializing
lock for its full duration (the same lock put/write/new
snapshots need), so writers and new-snapshot creation stall for
however long the largest populated level takes to rewrite. Default:
0 (disabled) — this is an explicit opt-in for callers who accept
that tradeoff for guaranteed physical removal of dead keys; use
[DB::compact]/[DB::compact_range] for an administrative,
caller-invoked equivalent instead if the stall is unacceptable.
block_cache: Option<Arc<BlockCachePool>>Optional shared block-cache pool. None (the default) gives this
DB a private cache sized by block_cache_capacity — the
historical behavior, unchanged. Some(pool) attaches this DB to
the caller-owned pool: DBs given the same Arc share one LRU
capacity (every key is namespaced by a per-DB member id, so
sharing is a capacity decision, never a correctness one), and
block_cache_capacity is ignored — capacity belongs to the
pool.
Implementations§
Source§impl DbOptions
Preset profiles for common workloads.
impl DbOptions
Preset profiles for common workloads.
Sourcepub fn write_heavy() -> Self
pub fn write_heavy() -> Self
Write-heavy profile — optimized for high write throughput.
Sourcepub fn read_heavy() -> Self
pub fn read_heavy() -> Self
Read-heavy profile — optimized for read latency.