Get started with queries in Cassandra drivers

The ability to send read/write queries (CQL statements) to your database is the core purpose of Cassandra drivers. As a result, almost every feature of a driver is designed to support query execution in some way, including performance optimization, reliability, error handling, and advanced use cases.

See the documentation for your driver to learn how to structure and send CQL queries:

Queries are submitted to databases through an instance of a driver root object (typically, a cluster). Don’t create separate root objects for specific keyspaces. Instead, create one root object per cluster and one long-lived driver session per application. Then, explicitly set keyspaces on statement objects, or use fully qualified keyspaces in your query strings.

Synchronous and asynchronous query execution

Most Cassandra drivers can execute queries against a database synchronously or asynchronously. The appropriate choice for your application depends on your use cases and requirements.

This means that the application sends a query to the database, and then the thread that sent the query waits for the query to complete before proceeding. In multi-threaded applications, other threads can continue to run while the query is processed. In single-threaded applications, this can block the entire application while waiting for the query result.

With synchronous query execution, it is easy to tell when a query completes, and this can make the application’s execution logic easier to follow. However, each thread can only execute one query at a time. While server nodes usually take less than a millisecond to fulfill a request, throughput can degrade when executing extremely large numbers of queries or while waiting for long-running queries to finish. If your application needs to process thousands or millions of queries, asynchronous query execution can be more performant.

Set consistency levels

Consistency levels determine how many replicas in a cluster must acknowledge a read or write operation before it is considered successful. For more information about consistency levels, see the documentation for your driver:

C/C++ driver

See Consistency.

C# driver

See ConsistencyLevel.

Go driver

There are several options for setting consistency level, including Consistency and Query.SerialConsistency.

Java driver

See the documentation for your version of the Java driver:

Node.js driver

See the documentation for your version of the Node.js driver:

Python driver

See the documentation for your version of the Python driver:

Data type conversion and representation

When executing queries, you often need to convert between the data types used in your application and the CQL data types used in the database. For more information about type conversion, see the documentation for your driver:

Next steps

To learn more about query execution with Cassandra drivers, explore your driver’s documentation and the other driver topics in the Astra documentation. For example:

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2026 | Privacy policy | Terms of use Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: Contact IBM