Are Dynamodb UUID hash keys better than sequentially generated ones

I think I understand the concept of not having hot hashcakes so that you use all partitions in bandwidth. But do UUID hashKeys do a better job of partitioning than numeric sequences? In both cases, is there a hash code generated from the key and a value that is assigned to the section? If so, how do the hash codes of the two strings "100444" and "100445" differ? Are they close?

+3


source to share


1 answer


"100444" and "100445" will most likely not be on the same partition than a completely different number, such as "12345". Think of a DynamoDB table as a large hash table where the hash key of the table is the key in the hash table. The main hash table is organized by the hash of the key, not by the key itself. You will find that numbers and strings (UUIDs) are distributed in DynamoDB in the order in which they are partitioned.

UUIDs are useful in DynamoDB because sequence numbers are difficult to generate in a scalable way for primary keys. Random numbers work well for primary keys, but sequential values ​​are difficult to generate without spaces and in a way that scales to the bandwidth you can provide in a DynamoDB table. When you insert new items into a DynamoDB table, you can use conditional records to ensure that the item does not already exist with that primary key value.



(Note: This question is also cross-posted on this AWS forum and discussed there as well).

+9


source







All Articles