3

I've tried using UUID's integer representation as integer hash key in DynamoDB, but that has failed with error:

DynamoDBValidationError: DynamoDBValidationError: 400 Bad Request
{'message': 'Attempting to store more than 38 significant digits in a Number', 
 '__type': 'com.amazon.coral.validate#ValidationException'}

Which on one hand makes sense, as UUIDs are 128-bit, which can be up to 39 decimal digits. On the other hand it made me wonder...

Does DynamoDB store integer hash key as it's decimal representation? Is there any advantage of using integer hash key over string hash key?

1 Answer 1

7

DynamoDB serializes numbers so there shouldn't be any advantage of using an integer hash key over a string hash key.

Serialized numbers are sent to Amazon DynamoDB as String types, which maximizes compatibility across languages and libraries, however Amazon DynamoDB handles them as the Number type for mathematical operations.

http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html

Sign up to request clarification or add additional context in comments.

1 Comment

DynamoDB sends numbers over the wire as strings, but what you quoted has nothing to do necessarily with how DynamoDB stores the values once they arrive at DynamoDB and are deserialized. I understand the question to be whether a numerical key would be more efficient stored in the DynamoDB table, by taking up less space and/or by providing faster lookups, and this answer doesn't address that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.