pub enum IsolationLevel {
ReadCommitted,
SnapshotIsolation,
Serializable,
}Expand description
Transaction isolation level.
Controls the consistency guarantees and performance tradeoffs for transactions.
§Comparison
| Level | Dirty Reads | Non-Repeatable Reads | Phantom Reads | Write Skew |
|---|---|---|---|---|
| ReadCommitted | No | Yes | Yes | Yes |
| SnapshotIsolation | No | No | No | Yes |
| Serializable | No | No | No | No |
§Performance
Higher isolation levels require more bookkeeping:
ReadCommitted: Only tracks writesSnapshotIsolation: Tracks writes + snapshot versioningSerializable: Tracks writes + reads + SSI validation
Variants§
ReadCommitted
Read Committed: sees only committed data, but may see different versions of the same row within a transaction.
Lowest overhead, highest throughput, but weaker consistency.
SnapshotIsolation
Snapshot Isolation (default): each transaction sees a consistent snapshot as of transaction start. Prevents non-repeatable reads and phantom reads.
Vulnerable to write skew anomaly.
Serializable
Serializable Snapshot Isolation (SSI): provides full serializability by detecting read-write conflicts in addition to write-write conflicts.
Prevents all anomalies including write skew, but may abort more transactions due to stricter conflict detection.
Trait Implementations§
Source§impl Clone for IsolationLevel
impl Clone for IsolationLevel
Source§fn clone(&self) -> IsolationLevel
fn clone(&self) -> IsolationLevel
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for IsolationLevel
impl Debug for IsolationLevel
Source§impl Default for IsolationLevel
impl Default for IsolationLevel
Source§fn default() -> IsolationLevel
fn default() -> IsolationLevel
Source§impl PartialEq for IsolationLevel
impl PartialEq for IsolationLevel
impl Copy for IsolationLevel
impl Eq for IsolationLevel
impl StructuralPartialEq for IsolationLevel
Auto Trait Implementations§
impl Freeze for IsolationLevel
impl RefUnwindSafe for IsolationLevel
impl Send for IsolationLevel
impl Sync for IsolationLevel
impl Unpin for IsolationLevel
impl UnwindSafe for IsolationLevel
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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