Misunderstanding on Composite Key for Cassandra

前端 未结 2 1319
-上瘾入骨i
-上瘾入骨i 2020-12-31 20:58

I\'ve to test different datamodels for Cassandra. I\'m thinking about to use a composite key made by key1:key2 for the row key. With this configuration on Cassandra, for ex

相关标签:
2条回答
  • 2020-12-31 21:23

    I hope these articles help you :)

    http://pkghosh.wordpress.com/2011/03/02/cassandra-secondary-index-patterns/

    http://www.datastax.com/docs/0.7/data_model/cfs_as_indexes

    http://www.anuff.com/2011/02/indexing-in-cassandra.html

    Also checkout this question

    Storing a list of values in Cassandra

    0 讨论(0)
  • 2020-12-31 21:36

    If you use Order Preserving Partitioning (OPP), then yes, the keys will be stored sorted, and then you can get slices over a range of keys e.g. A:A to A:Z -- but not necessarily any:A to any:Z.

    But, OPP is not guaranteed to evenly distribute the keys across the nodes and you could end up with "hot spots" of too many or too few keys. You probably want to use Random Partitioning (RP) which distributes the keys by storing by hash across all nodes.

    However, since Columns are stored sorted, using Composite values can be pretty powerful for accessing ranges of data.

    See this question for details on querying Composite columns using Hector .

    If necessary, the column names could then be used as keys to do Multiget queries for additional lookups.

    0 讨论(0)
提交回复
热议问题