DbOptions Class
Definition
Namespace: RocksDbSharp
public class DbOptions
DbOptions carries database-wide settings and is the first argument to every
RocksDb.Open* overload. Settings here apply to all column
families in the database.
Remarks
The setters are fluent — each returns the same DbOptions so calls can be
chained. Most values flow straight to native memory rather than being stored as
managed properties; to read effective state once the database is open, use
RocksDb.GetProperty. For per-column-family tuning
see ColumnFamilyOptions. The full
reference is on the DbOptions page.
Methods
| Name | Description |
|---|---|
SetCreateIfMissing(bool) |
Creates the database if the directory doesn't exist. |
SetCreateMissingColumnFamilies(bool) |
Auto-creates any column family missing at open time. |
SetErrorIfExists(bool) |
Fails open if the database already exists. |
SetParanoidChecks(bool) |
Aggressively validates on read. |
IncreaseParallelism(int) |
Bumps background compaction and flush threads at once. |
SetMaxBackgroundCompactions(int) |
Sets concurrent compactions. |
SetMaxBackgroundFlushes(int) |
Sets concurrent memtable flushes. |
SetMaxOpenFiles(int) |
Caps simultaneously open SST files. |
SetMaxTotalWalSize(ulong) |
Forces a flush when WALs exceed this size. |
SetWalDir(string) |
Puts the WAL on a separate volume. |
SetWalTtlSeconds(ulong) |
Sets how long old WAL files are retained. |
SetWalRecoveryMode(Recovery) |
Behaviour on recovery from a corrupt WAL. |
SetWalCompression(Compression) |
Compresses WAL records. |
EnableStatistics() |
Turns on statistics collection. |
GetStatisticsString() |
Returns the collected statistics as a string. |
OptimizeLevelStyleCompaction(ulong) |
Applies level-style compaction defaults. |
OptimizeUniversalStyleCompaction(ulong) |
Applies universal-style compaction defaults. |
SetCreateIfMissing
public DbOptions SetCreateIfMissing(bool value)
Creates the database if the directory doesn't exist. Default false.
SetCreateMissingColumnFamilies
public DbOptions SetCreateMissingColumnFamilies(bool value)
Auto-creates any column family that is missing at open time. Default false.
SetErrorIfExists
public DbOptions SetErrorIfExists(bool value)
Fails the open if the database already exists. Default false.
SetParanoidChecks
public DbOptions SetParanoidChecks(bool value)
Aggressively validates data on read. Default true.
IncreaseParallelism
public DbOptions IncreaseParallelism(int totalThreads)
One-liner shortcut that raises the number of background compaction and flush threads at once — the recommended starting point for non-tiny workloads.
SetMaxBackgroundCompactions
public DbOptions SetMaxBackgroundCompactions(int value)
Sets the number of concurrent compactions.
SetMaxBackgroundFlushes
public DbOptions SetMaxBackgroundFlushes(int value)
Sets the number of concurrent memtable flushes.
SetMaxOpenFiles
public DbOptions SetMaxOpenFiles(int value)
Caps the number of simultaneously open SST files. -1 keeps them all open.
SetMaxTotalWalSize
public DbOptions SetMaxTotalWalSize(ulong value)
When the total WAL size exceeds this value, the oldest backing column family is forced to flush.
SetWalDir
public DbOptions SetWalDir(string value)
Places the WAL on a separate, often faster, volume.
SetWalTtlSeconds
public DbOptions SetWalTtlSeconds(ulong value)
Controls how long old WAL files are retained — required for WAL replication. A
companion SetWalSizeLimitMB(ulong) bounds retention by size.
SetWalRecoveryMode
public DbOptions SetWalRecoveryMode(Recovery mode)
Sets the behaviour used when recovering from a corrupt WAL.
SetWalCompression
public DbOptions SetWalCompression(Compression compression)
Compresses WAL records, for example with Compression.Zstd.
EnableStatistics
public DbOptions EnableStatistics()
Turns on RocksDB statistics collection.
GetStatisticsString
public string GetStatisticsString()
Returns the collected statistics as a human-readable string.
OptimizeLevelStyleCompaction
public DbOptions OptimizeLevelStyleCompaction(ulong memtableMemoryBudget)
Applies level-style compaction defaults sized to the given memtable budget.
OptimizeUniversalStyleCompaction
public DbOptions OptimizeUniversalStyleCompaction(ulong memtableMemoryBudget)
Applies universal-style compaction defaults sized to the given memtable budget.
Applies to
RocksDbSharp — see DbOptions for the full setter reference and tuning notes.