How do you control the on-disk sort order of rows within a partition using CLUSTERING ORDER BY?
Last updated
CLUSTERING ORDER BYis set at table creation, givingASCorDESCper clustering column to define how rows are physically sorted on disk within each partition.Queries can only read in that order or its full reverse (not arbitrary sorts), and reversing costs slightly more, so pick the common query direction.
Typical use: time-series newest-first by clustering on a timestamp
DESC.
- https://aicassindra.com/blogs/cassandra/cassandra_data_modeling_basics.html
- https://docs.datastax.com/en/cql-oss/3.1/cql/ddl/ddl_compound_keys_c.html
- http://adamhutson.com/cassandra-partitioning-and-clustering-keys-explained/
- https://docs.scylladb.com/manual/stable/cql/dml/select.html
- https://www.scylladb.com/2019/03/28/the-new-cql-optimization-dashboard-in-scylla-monitoring-stack-2-2/
- https://cassandra.apache.org/doc/4.0/cassandra/cql/ddl.html
- https://cassandra.apache.org/doc/latest/cassandra/reference/cql-commands/create-table.html
- https://cassandra.apache.org/doc/3.11/cassandra/data_modeling/intro.html