pub struct DatabaseConfig {
pub group_commit: bool,
pub memtable_size_limit: usize,
pub wal_enabled: bool,
pub sync_mode: SyncMode,
pub read_only: bool,
pub enable_ordered_index: bool,
pub group_commit_config: GroupCommitSettings,
pub default_index_policy: IndexPolicy,
}Expand description
Database configuration
Fields§
§group_commit: boolEnable group commit for better write throughput
memtable_size_limit: usizeMaximum memory for memtables before flush (bytes)
wal_enabled: boolEnable WAL for durability
sync_mode: SyncModeSync mode: fsync after every commit vs periodic
read_only: boolRead-only mode
enable_ordered_index: boolUse default_index_policy field instead. This field will be removed in v0.3.0. Set IndexPolicy::ScanOptimized for ordered index, WriteOptimized to disable.
Enable ordered index for O(log N) prefix scans
§Deprecation Notice
DEPRECATED since 0.2.0: Use default_index_policy instead for per-table control.
This field will be removed in v0.3.0.
§Migration Guide
Replace:
DatabaseConfig { enable_ordered_index: true, .. } // Old API
DatabaseConfig { enable_ordered_index: false, .. } // Old APIWith:
DatabaseConfig { default_index_policy: IndexPolicy::ScanOptimized, .. } // Ordered index enabled
DatabaseConfig { default_index_policy: IndexPolicy::WriteOptimized, .. } // Ordered index disabled§Behavior
When false, saves ~134 ns/op on writes (20% speedup) but scan_prefix becomes O(N) instead of O(log N + K).
Set to false for write-heavy workloads without range scans.
Set to false for write-heavy workloads without range scans.
group_commit_config: GroupCommitSettingsGroup commit configuration
default_index_policy: IndexPolicyDefault index policy for tables not explicitly configured
This replaces the global enable_ordered_index toggle with
fine-grained per-table control. Use index_registry to configure
individual tables.
| Policy | Insert Cost | Scan Cost | Use Case |
|---|---|---|---|
| WriteOptimized | O(1) | O(N) | High-write, rare scan |
| Balanced | O(1) amort | O(output+logK) | Mixed OLTP |
| ScanOptimized | O(log N) | O(logN + K) | Analytics, range query |
| AppendOnly | O(1) | O(N) | Time-series logs |
Implementations§
Source§impl DatabaseConfig
impl DatabaseConfig
Sourcepub fn throughput_optimized() -> Self
pub fn throughput_optimized() -> Self
Create config optimized for throughput (Fast Mode)
- Disables ordered index (saves ~134 ns/op)
- Uses high-throughput group commit settings
- Suitable for append-only workloads
Sourcepub fn latency_optimized() -> Self
pub fn latency_optimized() -> Self
Create config optimized for latency
- Keeps ordered index for fast range scans
- Uses low-latency group commit settings
- Suitable for OLTP workloads
Sourcepub fn sqlite_compatible() -> Self
pub fn sqlite_compatible() -> Self
Create config matching SQLite defaults
Sourcepub fn effective_ordered_index(&self) -> bool
pub fn effective_ordered_index(&self) -> bool
Get effective ordered index setting, derived from default_index_policy.
This is the shim method for the deprecated enable_ordered_index field.
It returns true if the policy requires an ordered index (ScanOptimized),
and false otherwise (WriteOptimized, Balanced, AppendOnly).
§Policy Mapping
| IndexPolicy | Returns |
|---|---|
| ScanOptimized | true |
| Balanced | false |
| WriteOptimized | false |
| AppendOnly | false |
Note: Balanced uses lazy compaction rather than a live ordered index,
so it returns false for the low-level memtable config but still supports
efficient range scans via sorted runs.
Trait Implementations§
Source§impl Clone for DatabaseConfig
impl Clone for DatabaseConfig
Source§fn clone(&self) -> DatabaseConfig
fn clone(&self) -> DatabaseConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DatabaseConfig
impl Debug for DatabaseConfig
Auto Trait Implementations§
impl Freeze for DatabaseConfig
impl RefUnwindSafe for DatabaseConfig
impl Send for DatabaseConfig
impl Sync for DatabaseConfig
impl Unpin for DatabaseConfig
impl UnsafeUnpin for DatabaseConfig
impl UnwindSafe for DatabaseConfig
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more