In a new DynamoDB table, my use cases are already fulfilled by the following key schema design:
- partition key:
user_id - sort key:
entity_id
Basically, access patterns are:
- Get specific post by a specific user.
- Get specific comment by a specific user.
- List all posts by specific user.
- List all comments by specific user.
- List all entities (post or comment) by a specific user.
What benefits do I get if I use a more random ID as partition key instead and simply use GSIs for my access patterns above?
- partition key:
pseudo_random_id(This is going to be a UUID in reality. Please ignore that this is NOT a UUID in the illustration). - GSI:
- partition key:
user_id - sort key:
entity_id
- partition key:


pseudo_random_idvalues are not UUIDs. The term UUID has a very specific standardized meaning. A UUID is a 128-bit value, presented to humans in canonical format as 32 hex characters grouped by 4 hyphen characters. Example:403fc3f4-9bb9-11e9-a2a3-2a2ae2dbcce4. Please edit the title and body of your Question to make clear if you meant UUID or something else. - Basil Bourque