Search code examples
cassandradata-modelingcql

Is UUID or Integer a good choice as partition key?


Two simple questions:

  • Is a UUID a good choice as a partition key? Will this distribute data evenly among all nodes in the cluster?
  • Is a (unique) integer a good choice?

Will any of these options create "hot" partitions?

Thanks!


Solution

  • UUID is a good choice for partition key - it should be good distributed between cluster nodes. "Unique" integer is more tricky - some node need to be an authority for generation of this number, and this is hard to do in the distributed environment.

    Regarding hot partition - this will depend on your data model. If you have other primary key components besides the partition key, yes - you may have this problem. For example, you generate a random UUID for sensor & starting to write a lot of data into it.