Partitioners with the TOKEN function in Cassandra
Last Updated :
12 Jul, 2025
In this article we will discuss how TOKEN function works in
Cassandra using partitioners. There are 3 different type of partitioners that is supported by Cassandra Query Language.
Partitioners in CQL :
1. Murmur3partitioner
2. RandomPartitioner
3. ByteOrderedPartitioner
Let's discuss one by one.
- Murmur3partitioner :
It is default partitioner in Cassandra 3.0. If we used TOKEN function then it distribute data over cluster based on MurmurHash hash values. It is also useful to provide good performance and fast hashing.
- RandomPartitioner :
It is default partitioner prior to Cassandra 1.2. It distribute data over across cluster by using MD5 hash values.
- ByteOrderedPartitioner :
In Cassandra Query Language Byte Ordered partitioner data distribute over cluster based on data lexically by key bytes.It is used for ordered partitioning in Cassandra Query Language. It is also useful for backward compatibility.
Below given table is useful to understand, let's have a look.
Partitioner Name |
Data Type |
Distribute data over cluster based on |
Murmur3Partitioner |
bigint |
MurmurHash hash values |
RandomPartitioner |
varint |
MD5 hash values |
ByteOrderedPartitioner |
blob |
data lexically by key bytes |
Let's understand the TOKEN function using partitioning key and return query based on Token partitioning key. first we are creating table.
CREATE TABLE User_info
(
Id int,
Name text,
Address text,
PRIMARY KEY(Id, Name)
);
To insert data into table User_info used the following CQL Query:
INSERT INTO User_info (Id, Name, Address)
VALUES (301, 'Ashish', 'Delhi');
INSERT INTO User_info (Id, Name, Address)
VALUES (302, 'Rana', 'Mumbai');
INSERT INTO User_info (Id, Name, Address)
VALUES (303, 'Abi', 'Noida');
INSERT INTO User_info (Id, Name, Address)
VALUES (302, 'me', 'Noida');
Let's have a look.
SELECT *
FROM User_info;
Id |
Name |
Address |
301 |
Ashish |
Delhi |
302 |
Me |
Noida |
302 |
Rana |
Mumbai |
303 |
Abi |
Noida |
By using
TOKEN function.
SELECT TOKEN(Id)
FROM User_info;
Reference for practitioners, and
Reference for TOKEN function.
Similar Reads
Working with Partition in Cassandra In this article, we are going to cover how we can make partition as per our requirements and how we can handle data into tables with partition key. Let's discuss one by one. Pre-requisite â Overview of Data Modeling Partitioning for Data Modeling : Partition is the small set of rows where you can sa
2 min read
Working with Partition in Cassandra In this article, we are going to cover how we can make partition as per our requirements and how we can handle data into tables with partition key. Let's discuss one by one. Pre-requisite â Overview of Data Modeling Partitioning for Data Modeling : Partition is the small set of rows where you can sa
2 min read
Table Partitioning in Cassandra In this article, we are going to cover how we can our data access on the basis of partitioning and how we can store our data uniquely in a cluster. Let's discuss one by one. Pre-requisite â Data Distribution Table Partitioning : In table partitioning, data can be distributed on the basis of the part
2 min read
Table Partitioning in Cassandra In this article, we are going to cover how we can our data access on the basis of partitioning and how we can store our data uniquely in a cluster. Let's discuss one by one. Pre-requisite â Data Distribution Table Partitioning : In table partitioning, data can be distributed on the basis of the part
2 min read
Operations on table in Cassandra In this article, we will discuss table operations like Create insert truncate drop in Cassandra with some sample exercise. Letâs have a look. Creating a table - Register: First, we are going to create a table namely as Register in which we have id, name, email, city are the fields. Letâs have a look
3 min read
Operations on table in Cassandra In this article, we will discuss table operations like Create insert truncate drop in Cassandra with some sample exercise. Letâs have a look. Creating a table - Register: First, we are going to create a table namely as Register in which we have id, name, email, city are the fields. Letâs have a look
3 min read