DataStax Storage-Attached Indexing (SAI) lets you create one or multiple secondary indexes on the same database table, with each SAI index based on any column. SAI provides more functionality compared to Cassandra secondary indexes, is faster at writes compared to any Cassandra or DSE Search index, and uses significantly less disk space.
In this scenario, we'll learn how to:
- Create an Astra database
- Install and configure cqlsh
- Create a table in Astra
- Create SAI indexes on columns
- Perform SELECT queries based on indexed columns
Astra is a great Cassandra as a Service offering, making setup easy for us. Let's get started!
Using Storage-Attached Indexing (SAI) on Astra
Create your Astra Database
Defining one or more SAI indexes based on any column in a database table subsequently gives you the ability to run performant queries that specify the indexed column.
What is an index?An index provides a means to access data in Cassandra using attributes other than the partition key. The benefit of an index is fast, efficient lookup of data that matches a given condition.
First of all though, you are going to need to setup an Astra database and an initial keyspace. Astra is cloud-native Cassandra-as-a-Service, built on Apache Cassandra.
Have an existing Astra database and keyspace?
-- Move on to Step 2.
If you don't have an Astra account, set one up - it's easy.
Go to the Astra page in your browser: astra.datastax.com.
When you log in the first time you'll find yourself looking at the main Astra details screen. It'll look like this, which we have outlined in green the specific values you'll now want to fill in.
Once those are filled in click on “launch database”.
Don't forget your password - you will need it soon.