Scylla University Live | April 22 Free Virtual Training Event
Learn More >

Local Secondary Indexes and Combining Both Types of Indexes

6 min to complete

Local Secondary Indexes are conceptually similar to global indexes, but there’s one important difference – local indexes guarantee that for each base partition, the corresponding rows in the materialized view will end up on the same node. It’s achieved by using the same partition key in the underlying view as we use in the base table.
Querying involves the same steps, but they will query by the same partition key for both the index query and the base query
Not all queries are eligible for local secondary indexes. In order to be able to benefit from a local index, we must provide a partition key restriction as well. As a result, only a single view partition will be queried, and what’s more, the base rows we need to fetch are on the exact same node as the materialized view partition. Hence the name, *local* indexes.
Additionally, it’s perfectly legal to create several indexes on one table. Some of them may be local, some of them global, even if they refer to the same column.