Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum key size in Cassandra

Tags:

cassandra

I'm completely new to using cassandra.. is there a maximum key size and would that ever impact performance?

Thanks!

like image 598
blooberr Avatar asked May 24 '11 20:05

blooberr


2 Answers

The key (and column names) must be under 64K bytes.

Routing is O(N) of the key size and querying and updating are O(N log N). In practice these factors are usually dwarfed by other overhead, but some users with very large "natural" keys use their hashes instead to cut down the size.

like image 100
jbellis Avatar answered Oct 20 '22 20:10

jbellis


http://en.wikipedia.org/wiki/Apache_Cassandra claims (apparently incorrectly!) that:

The row key in a table is a string with no size restrictions, although typically 16 to 36 bytes long

See also:

http://cassandra-user-incubator-apache-org.3065146.n2.nabble.com/value-size-is-there-a-suggested-limit-td4959690.html which suggests that there is some limit.

Clearly, very large keys could have some network performance impact if they need to be sent over the Thrift RPC interface - and they would cost storage. I'd suggest you try a quick benchmark to see what impact it has for your data.

One way to deal with this might be to pre-hash your keys and just use the hash value as the key, though this won't suit all use cases.

like image 25
DNA Avatar answered Oct 20 '22 19:10

DNA