问题
In Cassandra , Will there be performance penalty if primary key is varchar instead of int or bigint ? I have id as primary key. I wont do any math operation on that. I use id just to insert,retrive compare. I want to change that to string for one of my requirements. Will the perforamnce go down ?
回答1:
There won't be any noticeable difference. Primary key lookups are done on the token i.e. the hash of the key. The comparisons are therefore independent of the data type or size of the key.
Longer keys will take slightly longer to hash. And there are some internal comparisons on the raw key but I very much doubt any of this is significant so go ahead and use whatever type is best for your data.
来源:https://stackoverflow.com/questions/20692446/cassandra-primary-key-performance-implications-if-integer-vs-varchar