Restricting queries using WHERE clauses

Tables have two types of columns with special roles: the partition key and the clustering columns. Together they define the primary key:

  • Partition key (PK) columns: The first part of primary key defines the hash that is used to spread data evenly across the data center.

  • Clustering columns: The last part of the primary key that orders the data within a partition.

Partition keys, clustering, and normal columns have different sets of restrictions within the WHERE clause. Those restrictions differ depending of the type of command: SELECT, UPDATE, or DELETE.

Partition keys

Identify partition keys to limit the query and retrieve data from specific nodes.

Clustering columns

Restrict queries on clustering columns and find ranges across clustering segments.

Retrieval using the IN keyword

Using the SELECT command with the IN keyword.

Sorting and limiting results

Using the SELECT command for simple queries.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

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: +1 (650) 389-6000,