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:
CREATE TABLE IF NOT EXISTS tbl_Employee
EmpID INT PRIMARY KEY
Insert a Sample record:
INSERT INTO tbl_Employee
SELECT Filtered data without Index:
SELECT *FROM tbl_Employee WHERE EmpFirstName='Anvesh';
SELECT data using ALLOW FILTERING option:
SELECT *FROM tbl_Employee WHERE EmpFirstName='Anvesh' ALLOW FILTERING;
Create an Index on column:
CREATE INDEX idx_tbl_Employee_EmpFirstNAme
Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.
If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.
I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.