Auto incrementing sequence generation in DynamoDb

0

I'm using AWS DynamoDB and seek assistance to generate auto-incrementing sequence numbers for my records. I appreciate any guidance or resources you can provide to effectively accomplish this task, considering DynamoDB's distributed nature.

asked a year ago2827 views
3 Answers
3

Your final comment sums up the request:

considering DynamoDB's distributed nature

As a distributed system, it's considered an anti pattern to have an auto-incrementing partition key (assuming that's the ask here). Instead you should think on choosing a partition key that can fulfill your read requirements without having to do full table Scans.

If guaranteed uniqueness is what you require, consider using a UUID or something similar along with a conditional update.

If the requirement is for non-key attributes, consider options outlined in this blog

profile pictureAWS
EXPERT
answered a year ago
2

I suggest checking out the following blog, which talks through several options for implementing resource counters and the considerations of each. https://aws.amazon.com/blogs/database/implement-resource-counters-with-amazon-dynamodb/

AWS
answered a year ago
1

DynamoDB does not support auto incrementing sequences. Still, you may find atomic counters useful in your case. See: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithItems.html#WorkingWithItems.AtomicCounters and https://aws.amazon.com/blogs/developer/using-atomic-counters-in-the-enhanced-dynamodb-aws-sdk-for-java-2-x-client/.

In my search, I also fount this possible solution: https://b itesizedserverless.com/b ite/reliable-auto-increments-in-dynamodb/

profile pictureAWS
EXPERT
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions