In this learning unit, you will:
- Query tables using the CQL
- Understand efficient data access patterns
- Learn about equality and inequality predicates
- Group rows and compute aggregates
- Order rows based on the table clustering order
- Use other CQL querying capabilities
This scenario is also available on our datastax.com/dev site, where you can find many more resources to help you succeed with Apache Cassandra™.
Did you know?
You can use Cassandra as a service in the cloud. Nothing to install, no credit card required. Sign up and launch your database with a few clicks at astra.datastax.com!
In this scenario, you learned about:
- CQL queries and the
- Efficient data access patterns
- Equality and inequality predicates
- Grouping rows and computing aggregates
- Ordering rows based on the table clustering order
- Other CQL querying capabilities
Queries in Apache Cassandra™
CQL queries look just like SQL queries. However, while you will see familiar clauses
ORDER BY, CQL queries are much more restrictive in what goes into those clauses.
A CQL query can only retrieve data from a single table, so there are no joins, self-joins, nested queries, unions, intersections and so forth.
Moreover, only columns that are declared in table's
PRIMARY KEY definition can be used to filter, group or order rows.
The primary key definition order must be respected when filtering and grouping, such that a complete partition key must be used and
when a clustering key column is used, any preceding clustering column in the primary key definition must also be used.
When ordering rows, the clustering order declared in the table definition must be respected. Ordering only applies to rows within a partition and
can be either preserved or reversed.
These restrictions ensure that your queries only use efficient data access patterns, which include retrieving one row, retrieving all rows or a subset of rows from one partition and retrieving rows from at most a few partitions. The smaller the number of partitions a query touches, the better performance and throughput can be expected. When studying our query examples in this tutorial, pay attention to data access patterns they implement.