Differentiate between a Partition Key and Clustering Columns. How do they influence data storage and retrieval?
Last updated
Partition key: hashed to choose node placement and groups rows on the same replicas. Queries must supply it fully, with equality only.
Clustering columns: physically sort rows within a partition, enabling cheap range scans and
ORDER BY. They must be filtered left to right.In short, the partition key handles distribution and locating data, while clustering columns handle ordering within a partition.
- https://cassandra.apache.org/doc/3.11/cassandra/data_modeling/intro.html
- https://cassandra.apache.org/doc/4.0/cassandra/cql/ddl.html
- https://www.scylladb.com/glossary/cassandra-clustering-key/
- https://www.youtube.com/watch?v=S9rmf4X7E_E
- https://docs.datastax.com/en/cql/hcd/get-started/key-concepts/partitions-and-keys.html
- https://sunitc.dev/2021/07/26/cassandra-primary-key-partition-key-and-clustering-keys/
- https://medium.com/systemdesign-us-blog/difference-between-partition-key-composite-key-and-clustering-key-in-cassandra-b68cb024017a
- https://medium.com/@abanoubwagih/understanding-cassandra-primary-keys-partition-key-clustering-columns-and-data-distribution-c61289d5289d