Reputation: 4024
1) As per datastax key cache stores the primary key index for rowkey.
2) In our case we have enough memory allocated for key cache and same key is present in multiple sstables with diffrent columns.
3) If no of calls are made to access all these same key from multiple sstables then how indexes are stored in key cache? will it store indexes for all the sstables OR just for the last sstable from which key is accessed recently?
Upvotes: 4
Views: 3624
Reputation: 5358
From Doc
The key cache holds the location of keys in memory on a per-column family basis.
Key cache serves as an index for a key in all sstables it is present.
Key cache is maintained per sstable. Hence key cache can save one disk seek per SSTable [minimum]. Every key lookup ends up hitting atleast the bloom filter of all sstable. On success key cache is verified just to skip the sstable index [pointers to key sample @ interval of 127 by default] lookup.
Read Path of cassandra goes like this
Memtable -> Row Cache (Off heap) -> Bloom filter -> Key cache -> SSTable Index [if miss] -> Disk
Everything in bold means they are maintained in memory (either in heap or off heap). Hence they don't add up to disk seek
Every sstable should be maintaining its own key cache. Souce from slide no 101 and Source2 from slide no 23
Incase of key cache miss, sstable index is used - that will give the clue over which 128th range might the key lie. From then disk seek for key starts [can be 1 to many].
I'll update the answer once again if I get any clue on how does cassandra descide on key cache size of every sstable may be [key_cache_conf/no_of_sstables]?
Upvotes: 5