6
votes

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
Possible duplicate of Are there any performance penalties when using a TEXT as a Primary Key?, which though newer I believe to have the better question and answer. - OrangeDog

1 Answers

9
votes

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.