Apache Cassandra Index Type

Traditional Secondary Indexes (2i) in Apache Cassandra: How It Works and When to Use It

Traditional 2i maintains per-node secondary index structures for non-primary-key columns. Coordinators may query matching nodes and combine results.

What Is a Traditional Secondary Indexes (2i) in Apache Cassandra?

Traditional 2i maintains per-node secondary index structures for non-primary-key columns. Coordinators may query matching nodes and combine results.

How the Traditional Secondary Indexes (2i) Algorithm Works

Traditional 2i maintains per-node secondary index structures for non-primary-key columns. Coordinators may query matching nodes and combine results.

Diagram showing the Traditional Secondary Indexes (2i) lookup algorithm
Conceptual Traditional Secondary Indexes (2i) algorithm. Exact behavior depends on the database version and query plan.

When to Use Traditional Secondary Indexes (2i)

Targeted secondary lookups after verifying suitability for the Cassandra release and data distribution.

How to Create a Apache Cassandra Traditional Secondary Indexes (2i)

Review data quality, existing structures, feature support, build time, and deployment requirements before creating an index on a production table.

CREATE INDEX IF NOT EXISTS orders_status_idx ON orders (status);

Traditional Secondary Indexes (2i) Query Example

This example demonstrates the matching query shape. Check the execution plan to confirm that the engine can use the index.

SELECT order_id FROM orders WHERE status = 'OPEN';

Queries Supported by Traditional Secondary Indexes (2i)

Targeted secondary lookups after verifying suitability for the Cassandra release and data distribution. A similar-looking predicate may not use the same access path; operators, expressions, key order, and data type all matter.

Read Performance, Storage, and Write Costs

Adds storage and write maintenance; read fan-out and latency can rise, especially for poor-cardinality choices. Indexes reduce some search work but require storage and add maintenance to writes.

Traditional Secondary Indexes (2i) Limitations and Common Mistakes

CREATE INDEX does not guarantee a cheap global lookup. Avoid indexing every column.

Do not assume that an index being present means the optimizer chose it or that the query became selective.

How to Measure and Tune Traditional Secondary Indexes (2i)

Benchmark selectivity, topology, concurrency, and coordinator fan-out; compare SAI or query tables.

Compare representative plans and timings before and after, including concurrent writes and realistic data volumes.

Traditional Secondary Indexes (2i) Questions

Will the database always use this index?

No. The optimizer weighs selectivity, estimated costs, statistics, cache state, and the amount of data returned.

What should I verify before production?

Confirm version support, query compatibility, write overhead, build/rollback procedures, and index behavior during backup and recovery.

Official Apache Cassandra Index Documentation

Check Apache Cassandra documentation: Indexing concepts for release-specific requirements and supported operators.