Search⌘ K
AI Features

Illustration: Partitioning

Explore how Apache Cassandra uses partitioning to distribute data rows across a cluster. Understand key concepts like keyspaces, replication factors, token functions, and how to access data on different nodes. This lesson provides practical guidance on creating tables and viewing data distribution using CQL and nodetool commands.

Illustration

To demonstrate partitioning, let’s create a simple table and insert some rows to see how they are distributed around the cluster.

Creating container keyspace for the table

A keyspace holds a related set of tables and defines the number of nodes that store copies of each row.

Creating a keyspace titled testkeyspace with replication factor 2
Creating a keyspace titled testkeyspace with replication factor 2

A replication_factor of 2 means each row of each table in this keyspace will be stored twice in the cluster—on two different nodes.

The USE <KEYSPACE> command selects the keyspace for all subsequent queries. Notice that cqlsh:>testkeyspace displaying testkeyspace has been selected for the ...