Overview
TheWriteOptions structure controls the behavior of write operations including Put(), Delete(), Merge(), and Write() (WriteBatch). It allows you to configure durability guarantees, write-ahead log behavior, and rate limiting.
Constructor
Options
bool
default:"false"
If true, the write will be flushed from the operating system buffer cache (by calling
WritableFile::Sync()) before the write is considered complete. Writes will be slower but more durable.sync=false: Similar crash semantics as thewrite()system callsync=true: Similar crash semantics towrite()followed byfdatasync()
bool
default:"false"
If true, writes will not go to the write-ahead log, and the write may be lost after a crash.Important: The backup engine relies on write-ahead logs. If you disable WAL, you must create backups with
flush_before_backup=true to avoid losing unflushed memtable data.bool
default:"false"
If true and user is trying to write to column families that don’t exist (they were dropped), ignore the write instead of returning an error. If there are multiple writes in a WriteBatch, other writes will still succeed.
bool
default:"false"
If true and the write needs to wait or sleep, fails immediately with
Status::Incomplete() instead of blocking.bool
default:"false"
Mark this write request as lower priority if compaction is behind.
- If
no_slowdown = true: Request canceled immediately withStatus::Incomplete() - If
no_slowdown = false: Request will be slowed down (slowdown value determined by RocksDB)
bool
default:"false"
If true, this WriteBatch maintains the last insert positions of each memtable as hints in concurrent writes. Can improve write performance if keys in one WriteBatch are sequential.Ignored in non-concurrent writes (when
concurrent_memtable_writes = false).Env::IOPriority
default:"Env::IO_TOTAL"
Charge the rate limiter at the specified priority. Special value
Env::IO_TOTAL disables charging the rate limiter.Currently covers automatic WAL flushes during live updates when disableWAL = false and manual_wal_flush = false.Only Env::IO_USER and Env::IO_TOTAL are allowed due to implementation constraints.size_t
default:"0"
Number of bytes used to store protection information for each key entry. Currently supported values are zero (disabled) and eight.
Examples
Durability vs Performance Trade-offs
See Also
- ReadOptions - Options for read operations
- WriteBatch - Atomic batch writes
- FlushOptions - Options for manual flush operations