On a given physical node, rows for a given partition key are stored in the order induced by the clustering keys, making the retrieval of rows in that clustering order particularly efficient. http://cassandra.apache.org/doc/cql3/CQL.html#createTableStmt What kind of ordering is induced by clustering keys?
相关问题
- What version of Java does Cassandra 3 require
- Filter from Cassandra table by RDD values
- spark select and add columns with alias
- cassandra: can you query against a collection fiel
- How to understand the 'Flexible schema' in
相关文章
- Cassandra Read a negative frame size
- How does cassandra split keyspace data when multip
- How does Cassandra scale horizontally ?
- Sorting a data stream before writing to file in no
- Modelling a Chat like Application in Firebase
- NoSQL Injection? (PHP->phpcassa->Cassandra)
- Executing CQL through Shell Script?
- Spark and Cassandra Java Application Exception Pro
Suppose your clustering keys are
where ki is the ith key name and ti is the ith key type. Then the order data is stored in is lexicographic ordering where each dimension is compared using the comparator for that type.
So (a1, a2, ..., an) < (b1, b2, ..., bn) if a1 < b1 using t1 comparator, or a1=b1 and a2 < b2 using t2 comparator, or (a1=b1 and a2=b2) and a3 < b3 using t3 comparator, etc..
This means that it is efficient to find all rows with a certain k1=a, since the data is stored together. But it is inefficient to find all rows with ki=x for i > 1. In fact, such a query isn't allowed - the only clustering key constraints that are allowed specify zero or more clustering keys, starting from the first with none missing.
For example, consider the schema
If you did the following inserts:
then they are stored in this order on disk (the order
select * from clustering where x = 'x'
returns):k1
ordering dominates, thenk2
, thenk3
.