Apache Cassandra 0.6 Documentation


This document corresponds to an earlier product version. Make sure you are using the version that corresponds to your version.

Latest Cassandra documentation | Earlier Cassandra documentation

UUIDs are used in Cassandra to avoid collisions.

To see how collisions can occur without UUIDs, consider that if multiple clients are writing to the same row simultaneously and timestamps are used for column names, it’s possible for a timestamp collision to occur, causing the first write to be overwritten by the second one. To prevent this and still allow columns to be sorted by time, a version 1 UUID can be used; these UUIDs include a timestamp component that Cassandra uses to sort the columns. In this case, Cassandra’s TimeUUIDType comparator should be used in the column family definition.

The other UUID types (versions 2 through 5) may also be used with Cassandra’s LexicalUUIDType comparator. These lack a time component and are sorted in byte order.

UUIDs can also be useful for row keys. Instead of incrementing keys based on a central authority, clients can simply generate version 1 UUIDs and rows will be stored in chronological order.