Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 779
Alex Tbk Avatar asked Aug 03 '18 06:08

Alex Tbk


People also ask

Why we should not use UUID?

If you're using a relational database as your application's source of truth, it has some variant of serial or auto-increment columns. Use those, you don't need UUIDs. They will bloat your tables and slow down your queries. Another one: non-sequential identifiers like UUIDs further destabilize keyset pagination.

Is UUID Dynamodb partition key good?

Choosing Keys For example, unique Partition keys based on UUID's is ideal.

Should I use UUID or ID?

By using UUIDs, you ensure that your ID is not just unique in the context of a single database table or web application, but is truly unique in the universe. No other ID in existence should be the same as yours.

What is the advantage of UUID?

Advantages: UUID values are unique between tables and databases. Thats why it can be merge rows between two databases or distributed databases. UUID is more safer to pass through url than integer type data.


1 Answers

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.

like image 74
Alex Ott Avatar answered Sep 21 '22 21:09

Alex Ott