ScyllaDB University Live | Free Virtual Training Event
Learn more
ScyllaDB Documentation Logo Documentation
  • Server
  • Cloud
  • Tools
    • ScyllaDB Manager
    • ScyllaDB Monitoring Stack
    • ScyllaDB Operator
  • Drivers
    • CQL Drivers
    • DynamoDB Drivers
  • Resources
    • ScyllaDB University
    • Community Forum
    • Tutorials
Download
ScyllaDB Docs ScyllaDB C# driver Features Driver components Core component Statements Batch statements

Batch statementsΒΆ

Use BatchStatement to execute a set of queries as an atomic operation (refer to [Batching inserts, updates and deletes][batch_dse] to understand how to use batching effectively):

PreparedStatement preparedInsertExpense =
    session.Prepare(
        "INSERT INTO cyclist_expenses (cyclist_name, expense_id, amount, description, paid) "
            + "VALUES (:name, :id, :amount, :description, :paid)");
SimpleStatement simpleInsertBalance =
    new SimpleStatement(
        "INSERT INTO cyclist_expenses (cyclist_name, balance) VALUES (?, ?) IF NOT EXISTS",
        "Vera ADRIAN", 0);

BatchStatement batch =
  new BatchStatement()
      .SetBatchType(BatchType.Logged)
      .Add(simpleInsertBalance)
      .Add(preparedInsertExpense.bind("Vera ADRIAN", 1, 7.95f, "Breakfast", false));

session.Execute(batch);

As shown in the examples above, batches can contain any combination of simple statements and bound statements.

A given batch can contain at most 65536 statements. Past this limit, addition methods throw an ArgumentOutOfRangeException.

Note that Cassandra batches are not suitable for bulk loading, there are dedicated tools for that (like the DataStax Bulk Loader). Batches allow you to group related updates in a single request, so keep the batch size small (in the order of tens).

In addition, simple statements with named parameters are currently not supported in batches (this is due to a protocol limitation that will be fixed in a future version).

Was this page helpful?

PREVIOUS
Statements
NEXT
Per-query keyspace
  • Create an issue
  • Edit this page
ScyllaDB C# driver
  • master
    • master
  • Features
    • Address resolution
    • Authentication and Authorization
    • Automatic failover
    • Column Encryption
    • Driver components
      • ADO.NET
      • Core component
        • Statements
          • Batch statements
          • Per-query keyspace
          • Prepared statements
          • Simple statements
      • Linq component
        • Batch statements with LINQ
      • Mapper component
        • Batch statements with the Mapper
    • Connection heartbeat
    • Connection pooling
    • CQL data types to C# types
      • Date and time representation
      • Nulls and unset
    • Execution Profiles
    • Graph support
    • Cluster and schema metadata
    • Metrics
      • App.Metrics Provider
      • List of metrics
    • Native protocol
    • OpenTelemetry
    • Result paging
    • Parameterized queries
    • Query timestamps
    • Query warnings
    • Request Tracker
    • Routing queries
    • Speculative query execution
    • TLS/SSL
    • Tuning policies
    • User-defined functions and aggregates
    • User-defined types
    • Vector support
  • FAQ
  • Upgrade Guide
  • Examples
  • API Reference
Docs Tutorials University Contact Us About Us
© 2025 ScyllaDB | Terms of Service | Privacy Policy | ScyllaDB, and ScyllaDB Cloud, are registered trademarks of ScyllaDB, Inc.
Last updated on 01 Aug 2025.
Powered by Sphinx 7.4.7 & ScyllaDB Theme 1.8.7
Ask AI