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

Formats the value using the given formatter. Read more
Source§

impl Default for OdbcBufferSettings

Source§

fn default() -> Self

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,