问题
Cassandra uses LSM tree for storage, but what exactly is the index structure of cassandra ? For e.g Both Mongo and Couchbase use BTree.
回答1:
It depends on the version of Cassandra you are actually using.
For version prior to 3.4 indexes are implemented as hidden Cassandra tables holding the key value of the data you wish to access. Main disadvantage of this strategy is that since SStables are subjected to compactions, you cannot reference data directly, instead you are given a key, and you have to go through the read path again.
In version 3.4 they introduced SASI indexes (SSTable Attached Secondary Indexes). Basically a portion of the index is associated to each SStable and hence distributed with it. This means you can actually use references to access data rather than pay for another read path. In terms of implementation, they are b-trees.
Here is a really useful resource on the subject.
来源:https://stackoverflow.com/questions/41759807/what-is-the-index-structure-of-cassandra