Skip to main content

DbOptions

Struct DbOptions 

Source
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: bool

Create the database directory if it does not exist.

§error_if_exists: bool

Return an error if the database already exists.

§write_buffer_size: usize

Size of a single MemTable in bytes before it is frozen.

§max_immutable_memtables: usize

Currently 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: usize

Number of L0 files that triggers compaction.

§target_file_size_base: u64

Target size for SST files in bytes.

§max_bytes_for_level_base: u64

Max total size of L1 in bytes.

§max_bytes_for_level_multiplier: f64

Multiplier between levels.

§num_levels: usize

Maximum number of levels (including L0).

§block_size: usize

Block size for SST data blocks.

§block_restart_interval: usize

Restart interval for prefix compression in data blocks.

§bloom_bits_per_key: u32

Bits per key for bloom filter. 0 disables bloom filter.

§compression: CompressionType

Compression type for SST data blocks.

§block_cache_capacity: u64

Block cache capacity in bytes. 0 disables caching.

§max_open_files: u64

Maximum number of TableReader entries retained by the table cache. Live Versions and iterators can pin additional readers.

§l0_slowdown_trigger: usize

Number of L0 files that triggers write slowdown.

§l0_stop_trigger: usize

Number of L0 files that stops writes until compaction completes.

§rate_limiter_bytes_per_sec: u64

Optional rate limiter for compaction writes (bytes/sec). 0 = no limit.

§prefix_len: usize

Fixed 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: usize

Maximum number of background compaction threads. Default: 1. RocksDB equivalent: max_background_compactions / increase_parallelism.

§max_subcompactions: usize

Maximum 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: bool

Eagerly 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: usize

When 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.

Source

pub fn balanced() -> Self

Balanced profile — good for mixed read/write workloads.

Source

pub fn write_heavy() -> Self

Write-heavy profile — optimized for high write throughput.

Source

pub fn read_heavy() -> Self

Read-heavy profile — optimized for read latency.

Trait Implementations§

Source§

impl Clone for DbOptions

Source§

fn clone(&self) -> DbOptions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DbOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DbOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more