OdbcBufferSettings

Struct OdbcBufferSettings 

Source
pub struct OdbcBufferSettings {
    pub batch_size: usize,
    pub max_column_size: Option<usize>,
}
Available on crate feature odbc only.
Expand description

Configuration for ODBC buffer settings that control memory usage and performance characteristics.

These settings affect how SQLx fetches and processes data from ODBC data sources. Careful tuning of these parameters can significantly impact memory usage and query performance.

ยงBuffered vs Unbuffered Mode

The buffer settings control two different data fetching strategies based on max_column_size:

Buffered Mode (when max_column_size is Some(value)):

  • Fetches rows in batches using columnar buffers for better performance with large result sets
  • Pre-allocates memory for all columns and rows in each batch using ColumnarAnyBuffer
  • WARNING: Long textual and binary field data will be truncated to max_column_size
  • Better for high-throughput scenarios where memory usage is acceptable
  • Uses batch_size to control how many rows are fetched at once

Unbuffered Mode (when max_column_size is None):

  • Fetches rows in batches using the next_row() method for memory efficiency
  • Processes rows in batches of batch_size but without pre-allocating columnar buffers
  • No data truncation - handles variable-sized data dynamically
  • More memory efficient than buffered mode but potentially slower
  • Better for scenarios where data sizes vary significantly or memory is constrained

Fieldsยง

ยงbatch_size: usize

The number of rows to fetch in each batch during bulk operations.

Performance Impact:

  • Higher values reduce the number of round-trips to the database but increase memory usage
  • Lower values reduce memory usage but may increase latency due to more frequent fetches
  • Typical range: 32-512 rows
  • Used in both buffered and unbuffered modes

Memory Impact:

  • In buffered mode: Each batch allocates buffers for batch_size * number_of_columns cells
  • In unbuffered mode: Each batch processes batch_size rows without pre-allocation
  • For wide result sets, this can consume significant memory

Default: 128 rows

ยงmax_column_size: Option<usize>

The maximum size (in characters) for text and binary columns when the database doesnโ€™t specify a length.

Performance Impact:

  • When Some(value): Enables buffered mode with batch fetching and pre-allocated buffers
  • When None: Enables unbuffered mode with batched row-by-row processing
  • Higher values ensure large text fields are fully captured but increase memory allocation
  • Lower values may truncate data but reduce memory pressure
  • Affects VARCHAR, NVARCHAR, TEXT, and BLOB column types

Memory Impact:

  • When Some(value): Directly controls buffer size for variable-length columns
  • When None: Minimal memory allocation per row, no truncation
  • Setting too high can waste memory; setting too low can cause data truncation
  • Consider your data characteristics when tuning this value

Default: Some(4096)

Trait Implementationsยง

Sourceยง

impl Clone for OdbcBufferSettings

Sourceยง

fn clone(&self) -> OdbcBufferSettings

Returns a duplicate of the value. Read more
1.0.0 ยท Sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Sourceยง

impl Debug for OdbcBufferSettings

Sourceยง

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Sourceยง

impl Default for OdbcBufferSettings

Sourceยง

fn default() -> OdbcBufferSettings

Returns the โ€œdefault valueโ€ for a type. Read more
Sourceยง

impl PartialEq for OdbcBufferSettings

Sourceยง

fn eq(&self, other: &OdbcBufferSettings) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท Sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Sourceยง

impl Copy for OdbcBufferSettings

Sourceยง

impl Eq for OdbcBufferSettings

Sourceยง

impl StructuralPartialEq for OdbcBufferSettings

Auto Trait Implementationsยง

Blanket Implementationsยง

Sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

Sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Sourceยง

impl<T> CloneToUninit for T
where T: Clone,

Sourceยง

unsafe fn clone_to_uninit(&self, dest: *mut u8)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Sourceยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Sourceยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Sourceยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

Sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Sourceยง

impl<T> IntoEither for T

Sourceยง

fn into_either(self, into_left: bool) -> Either<Self, Self> โ“˜

Converts 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 more
Sourceยง

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ“˜
where F: FnOnce(&Self) -> bool,

Converts 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
Sourceยง

impl<T> Same for T

Sourceยง

type Output = T

Should always be Self
Sourceยง

impl<T> ToOwned for T
where T: Clone,

Sourceยง

type Owned = T

The resulting type after obtaining ownership.
Sourceยง

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Sourceยง

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
Sourceยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Sourceยง

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Sourceยง

fn vzip(self) -> V

Sourceยง

impl<T> ErasedDestructor for T
where T: 'static,