Cassandra UUID vs TimeUUID benefits and disadvantages

前端 未结 3 718
我寻月下人不归
我寻月下人不归 2020-12-04 17:57

Given that TimeUUID handily allows you to use now() in CQL, are there any reasons you wouldn\'t just go ahead and always use TimeUUID instead of plain old UUID?

3条回答
  •  不思量自难忘°
    2020-12-04 18:05

    All said, you need to generate some to believe them. Timeuuids are Version/Level 1 UUID only seem to randomize the first 8 characters as you can see below, so, there is some chance of conflict, but still timeuuid is better than using timestamp itself. If uuid randomness is important, using Version/Level 4 UUID is a better choice with an almost improbable collision.

    So, it feels like if you don't care about uniqueness across partitions and your partitions are wide row time series data with high writes and need some unique identifier for each event (time), its a good choice that also has the benefit of clustering, pagination, etc.,.

    insert into test_tuuid(1, now())
    insert into test_tuuid(1, now())
    insert into test_tuuid(1, now())
    insert into test_tuuid(1, now())
    
    49cbda60-961b-11e8-9854-134d5b3f9cf8
    49d1a6c1-961b-11e8-9854-134d5b3f9cf8
    49d59e61-961b-11e8-9854-134d5b3f9cf8
    49d8d2b1-961b-11e8-9854-134d5b3f9cf8
    

提交回复
热议问题