-1

Currently I have a dynamodb (of which I cant anymore change the way the data is structured) which has a partition and sortKey but both are pretty much used as the composite primary key of the data (like you have with relational databases). Here an example of the structure:

partitionKey sortKey     sendMessageTime
id-1         target-1  
id-1         target-2
id-1         message-1/1 dateTime
id-1         message-1/2 dateTime

In here you can see that id would be the same for all the different sortKeys and only the sortKeys are a bit different but not really sortable (the id's in the DB are UUID). Is there a way to make it sortable on sendMessageTime (which is only present with the message-* sortKey) or is my only option to handle this in code? Wanted to limit the amount of message-1/* records I retrieve from dynamodb.

1 Answer 1

0

There are a number of ways you can address this, but it may mean adding an additional attribute to your items to index on.

Have a read of this blog post which outlines what your asking:

https://aws.amazon.com/blogs/database/effective-data-sorting-with-amazon-dynamodb/#:~:text=The%20sort%20key%2C%20also%20known,values%20of%20the%20sort%20key.

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

Comments

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.