Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UUID data type in DynamoDB

A UUID is, according to the specification, 128 bits or 16 bytes. The hexadecimal representation is 36 characters including the hyphens. I'm building a new table on DynamoDB and I have to decide the Type for the Hash key which I plan on filling with UUIDs. Should I create the table with a Hash key that is a String or Binary for these UUIDs? My gut tells me byte, because its less than half the size so that saves bandwidth, space, etc.

Does anybody have experience one way or the other and have a good reason to go with one over the other?

like image 201
Max Avatar asked Feb 19 '14 18:02

Max


People also ask

What is DynamoDB UUID?

For example, if you have a User table, you might have a UUID as a primary key that uniquely identifies each user, but you might also have user name and email fields (“attributes” in DynamoDB terminology), which also must be unique for that user.

What type of data is stored in DynamoDB?

DynamoDB supports the following data types: Scalar – Number, String, Binary, Boolean, and Null. Multi-valued – String Set, Number Set, and Binary Set.

Which of the data type is not supported by DynamoDB?

DynamoDB does not support empty sets, however, empty string and binary values are allowed within a set.

What is key type in DynamoDB?

There are two types of primary keys in DynamoDB: Partition key: This is a simple primary key. If the table has only a partition key, then no two items can have the same partition key value. Composite primary key: This is a combination of partition key and sort key.


1 Answers

I personally prefer using as many String based attributes/keys as possible mainly because it is easier to debug those in the AWS DynamoDB console.

I also feel that binaries were added for compressed and raw binary data which IMO UUIDs are not.

From a pure performance view, you are probably right - but I would stick with readable UUID String representations.

like image 147
Chen Harel Avatar answered Sep 18 '22 23:09

Chen Harel