Bulk Reading in Cassandra

In this article, we are going to describe how we can read in bulk which also helps in improve the performance. Before going to this article please understand the basic Architecture in Cassandra.

We are going to creating data schema for exercise to test the bulk reading in Cassandra.

Let’s have a look.
First, we are going to create table.

Table Schema to be created:

keyspace name - cluster1
Table name - user_data_app 



column-name Data Types
id uuid
name text
status text

Now, let’s write the CQL query to create the above given table schema.

create table user_data_app
 (
  id uuid primary key,
  name text,
  status text 
 ); 

Now, let’s insert data into the table. Given below is the CQL query to insert the rows in table.

Insert into user_data_app(id, name, status) 
values(uuid(), 'Ashish', 'ok');

Insert into user_data_app(id, name, status) 
values(uuid(), 'amit', 'in processing');

Insert into user_data_app(id, name, status) 
values(uuid(), 'Bhagyesh', 'ok');

Insert into user_data_app(id, name, status) 
values(uuid(), 'Alice', 'in processing');

Insert into user_data_app(id, name, status) 
values(uuid(), 'Bob', 'ok'); 

Now, let’s see the results that data successfully added. To verify the results used the following CQL query given below.

SELECT token(id) 
FROM user_data_app; 

Output:

Now, we are going to find out the token id of partitioning column by which we can perform the comparison and also we will use to perform bulk read.

SELECT token(id) 
FROM user_data_app; 

Output:

Now, let’s see the below CQL query which we will use for bulk reading.

SELECT token(id), id, name, status 
FROM user_data_app 
WHERE 
token(id) >-4888959478479554900 
AND
token(id) <= 1914029651463748596; 

Output:

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.