Reputation: 203
I am trying to set up a cassandra column family with secondary indexes on a few columns I will need to filter by when reading data back out. In my initial testing, when I use multiple indexes together, things slow down. Here is how I have it configured currently (via cassandra-cli):
update column family bulkdata with comparator=UTF8Type and column_metadata=[{column_name: test_field, validation_class: UTF8Type}, {column_name: create_date, validation_class: LongType, index_type: KEYS}, {column_name: domain, validation_class: UTF8Type, index_type: KEYS}];
I want to get all data where create_date > somevalue1 and column_name = somevalue2. Using pycassa for my client I do the following:
domain_expr = create_index_expression('domain', 'whatever.com')
cd_expr = create_index_expression('create_date', 1293650000, GT)
clause = create_index_clause([domain_expr, cd_expr], count=10000)
for key, item in col_fam.get_indexed_slices(clause):
...
This is a common mistake in SQL of course, where one would normally have to create a compound index, based on the query needs. I'm quite new to cassandra though, so I don't know if such a thing is required or even exists.
My interactions with cassandra will include large numbers of writes, and large numbers of reads and updates. I have set up the indexes figuring they were the right thing to do here, but perhaps I am completely wrong. I'd be interested in any ideas for setting up a performant system, with my index setup or without.
oh, and this is on cassandra 0.7.0-rc3
Upvotes: 8
Views: 4339
Reputation: 663
Native Cassandra secondary indexes have some limitations. They are not supposed to be used for columns with high cardinality (too many unique values), according to datastax documentation. It seems like the create_date column you are indexing on will have high cardinality. Also, there is no such thing as compound index in native Cassandra index support.
For more in depth coverage, you can visit my blog post http://pkghosh.wordpress.com/2011/03/02/cassandra-secondary-index-patterns/
Pranab
Upvotes: 9