1
votes

can cassandra use multiple native secondary indexes when querying on mutiple indexed columns?

using the canonical example from http://www.datastax.com/dev/blog/whats-new-cassandra-07-secondary-indexes

assuming a users column family with indexes both on birth date and state:

create column family users with comparator=UTF8Type
  and column_metadata=[{column_name: full_name, validation_class: UTF8Type},
  {column_name: birth_date, validation_class: LongType, index_type: KEYS},
  {column_name: state, validation_class: UTF8Type, index_type: KEYS}];

when I query:

get users where state = 'UT' and birth_date = 1970;

does cassandra uses both indexes to fetch the rows?

based on Compound Indexes in Apache Cassandra it seems the answer is no

1

1 Answers

2
votes

The link you give is correct; Cassandra will pick the most-selective index and use a nested loop to evaluate other predicates.