Scan dynamodb table in sorted order based on a attribute

0 votes

I have a dynamo db table. I want the list of values returned and sorted based on an attribute. My question is do I need to create a global secondary index for this? If that is the case, what should be the hash key, what is the range key?

Apr 4 in AWS by Archana
• 5,560 points
589 views

1 answer to this question.

0 votes

If you are aware of the HashKey, then any query will return the items sorted by Range key. This is an extract form AWS Documentation:

"Query results are always sorted by the sort key value. If the data type of the sort key is Number, the results are returned in numeric order; otherwise, the results are returned in order of UTF-8 bytes. By default, the sort order is ascending. To reverse the order, set the ScanIndexForwardparameter to false."

So, i don't think its possible to order the results of scan

answered Apr 4 by datageek
• 3,040 points

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer