Indexing a column

Using cqlsh to create an index on column values.

You can use cqlsh to create an index on column values. Indexing can impact performance greatly. Before creating an index, be aware of when and when not to create an index.

Procedure

  1. Creates an index on the state and birth_year columns in the users table.
    cqlsh:demodb> CREATE INDEX state_key ON users (state);
    cqlsh:demodb> CREATE INDEX birth_year_key ON users (birth_year);
  2. Query the columns that are now indexed.
    cqlsh:demodb> SELECT * FROM users
                    WHERE gender = 'f' AND
                    state = 'TX' AND
                    birth_year > 1968
                    ALLOW FILTERING;