What is a TimeUUID in Cassandra, and when would you use it instead of a regular UUID?
Last updated
timeuuidis a version-1 UUID embedding a timestamp, so values are globally unique and sort chronologically.A regular
uuid(version 4) is random with no meaningful order: use it when you only need uniqueness, like surrogate keys.Prefer
timeuuidas a clustering column for time-series/event data, queried with helpers likenow(),minTimeuuid(),maxTimeuuid().
- https://docs.datastax.com/en/cql-oss/3.3/cql/cql_reference/uuid_type_r.html
- https://docs.datastax.com/en/cql/hcd/reference/uuid.html
- https://cassandra.apache.org/doc/3.11/cassandra/cql/functions.html
- https://hyring.com/jobseeker-toolkit/interview-questions/technical/cassandra
- https://reintech.io/blog/implementing-time-series-data-cassandra
- https://medium.com/@shubham.patel191295/cassandra-for-system-design-interviews-when-to-pick-it-how-it-shards-and-every-question-youll-5542335def0e
- https://github.com/datastax/csharp-driver/blob/master/src/Cassandra/TimeUuid.cs