Reputation: 113
Why in Cassandra keys usually defined as UUID. Looks like the key is generated on client side, so why not just store as string? What's benefit of storing specifically as UUID?
Upvotes: 3
Views: 960
Reputation: 125
This saves disk space when there are a large number of rows.
Down increase performance by reducing the amount of data to fetch off disk, when there is a large number if rows.
Upvotes: 1
Reputation: 6380
One might have any key with Cassandra, a key is a bytearray
anyway. If clients wants to have key like "foobar" or any other string of arbitrary length, there is nothing wrong with it. Cassandra client converts it into into an array of bytes before transmission to Cassandra server. Technically it will be stored as "foobar" on the server side.
There are other things one need to consider when deciding on key format:
get
, to slice
and overly ignored delete
, often people find that UUID is a good compromise Upvotes: 4
Reputation: 16576
Cassandra Keys can be defined as any type (or combination therof) so you aren't restricted to UUID.
But as to why you would use a UUID over a string:
A UUID is 128 bits. A string is variable length and the string hexadecimal representation of the UUID would require 32 characters. If you were using 16-bit unicode characters that means each key would require 512s bit or 4 times as much space.
Upvotes: 3