blooberr
blooberr

Reputation: 338

Maximum key size in Cassandra

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

Thanks!

Upvotes: 5

Views: 5612

Answers (2)

DNA
DNA

Reputation: 42597

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.

Upvotes: 1

jbellis
jbellis

Reputation: 19377

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.

Upvotes: 15

Related Questions