SNAPSHOTREAD
Enables or disables snapshot read mode for the current session.
Syntax
Section titled “Syntax”SNAPSHOTREAD <ON | OFF>Parameters
Section titled “Parameters”| Parameter | Required | Description |
|---|---|---|
ON | Yes (one of) | Enables snapshot read mode on the session. |
OFF | Yes (one of) | Disables snapshot read mode on the session. |
Exactly one of ON or OFF must be provided. The argument is case-insensitive.
Return Value
Section titled “Return Value”Simple string: OK on success.
Behavior
Section titled “Behavior”The command sets or clears snapshot read mode on the current session. When enabled, subsequent FoundationDB reads performed by the session use snapshot isolation instead of the default serializable isolation.
Snapshot reads do not create read conflict ranges, which means they will not cause transactions to conflict with concurrent writes to the same keys. This is useful for long-running reads or read-heavy workloads where strict serializability is not required, and reducing transaction conflicts is more important than guaranteeing a perfectly consistent view.
The setting is session-scoped. It persists until explicitly changed or the session ends. It can be toggled at any time, regardless of whether a transaction is currently active.
Supported Commands
Section titled “Supported Commands”The following commands honor the SNAPSHOTREAD setting:
| Command | Honors SNAPSHOTREAD |
|---|---|
ZGET | Yes |
ZGETI64 | Yes |
ZGETF64 | Yes |
ZGETD128 | Yes |
ZGETRANGE | Yes |
ZGETKEY | Yes |
ZGETRANGESIZE | Yes |
BUCKET. | Yes |
BUCKET. | No, always uses serializable reads |
BUCKET. | No, always uses serializable reads |
BUCKET. | No, always uses serializable reads |
Mutation commands (BUCKET.INSERT, BUCKET.DELETE, BUCKET.UPDATE) always use serializable reads regardless of the
SNAPSHOTREAD setting.
Errors
Section titled “Errors”| Error Code | Description |
|---|---|
ERR | illegal argument for SNAPSHOTREAD: '<value>': The argument is neither ON nor OFF. |
Examples
Section titled “Examples”Enable snapshot read mode:
> SNAPSHOTREAD ONOKDisable snapshot read mode:
> SNAPSHOTREAD OFFOKInvalid argument:
> SNAPSHOTREAD MAYBE(error) ERR illegal argument for SNAPSHOTREAD: 'MAYBE'