pub struct BatchingSqlClient /* private fields */ A SQL client that automatically batches INSERT statements for high-performance bulk loading.
When you execute INSERT statements in a loop, this client accumulates them and automatically flushes through BulkInserter<GenericRecord> when the batch size is reached. This provides massive performance improvements over executing individual INSERT statements.
Example
Implementations
Create a new batching SQL client.
kinetica- The Kinetica clientbatch_size- Number of records to accumulate before flushing (recommended: 10000-50000)num_workers- Number of parallel workers for BulkInserter (recommended: 4-16)
pub fn with_options( kinetica: Arc<Kinetica>, batch_size: usize, num_workers: usize, options: BulkInserterOptions, ) -> Self
Create a batching client with custom options (e.g., upsert mode).
Create a batching client with SQL hints.
pub fn with_options_and_hints( kinetica: Arc<Kinetica>, batch_size: usize, num_workers: usize, options: BulkInserterOptions, hints: SqlHints, ) -> Self
Create a batching client with both BulkInserter options and SQL hints.
Set SQL hints for non-INSERT statements.
Note: For INSERT statements, hints like update_on_existing_pk are automatically applied through the BulkInserter options. Use with_hints() constructor to set both at creation time.
Execute a SQL statement.
- INSERT statements are accumulated and batched automatically
- Other statements (SELECT, CREATE, etc.) are executed immediately with hints applied
When the batch size is reached, records are automatically flushed through BulkInserter<GenericRecord> with shard-aware routing.
For non-INSERT statements, any configured SQL hints (via set_hints() or with_hints()) will be applied to the execute_sql request.
pub async fn flush(&mut self) -> SqlOpResult<()>
Flush all pending records for all tables.
pub async fn close(self) -> SqlOpResult<BatchingStats>
Flush all pending records and return final statistics.
This should be called when you’re done inserting to ensure all records are flushed.
pub fn stats(&self) -> BatchingStats
Get current statistics without closing.
pub fn pending_count(&self) -> usize
Get the number of pending (unflushed) records across all tables.