NoSQL: Create your first Index on Cassandra Column

In this post, I am going to share basic details about the Cassandra Indexes.

The architecture of Cassandra Index is very similar to RDBMS Indexes.
Like, The Primary Key column is a default indexed column and don’t require to create additional index on the Primary key column.

You can use CREATE INDEX command to create an index on the particular column.
Cassandra supports the different Collection data type in which you cannot create an Index.

In the older version of CQL, Index must be created on the filtered column and without applying Index on column you cannot use that column as a filter in WHERE clause.

In the Cassandra, it is advisable to create an Index on filtered column.
In the latest version of CQL, If you are trying to access filtered data without an Index, then It generates the error like “filtering may have unpredictable performance”. Still, you can SELECT filter the data without indexes, but you should use ALLOW FILTERING option with SELECT statements.

One of the flexibility of the Cassandra Index is: you can also create a custom index by specifying storage option.

Create a sample Table:

Insert a Sample record:

SELECT Filtered data without Index:

SELECT data using ALLOW FILTERING option:

Create an Index on column:

NoSQL Cassandra Allow Filtering Option

Anvesh Patel

Leave a Reply

Be the First to Comment!

Notify of