I am currently using DynamoDB and having a problem scanning. I am able to get paged results in forward order by using the ExclusiveStartKey. However, regardless of whether I set ScanIndexForward
true or false, I get results in forward order from my scan operation. How can i get results in reverse order from a Scan
in DynamoDB?
相关问题
- Assume/switch role in aws toolkit for eclipse 2.0
- .Net Core DynamodDB unit testing with XUnit
- AWSCognito Missing region in config error
- AWS Amplify MissingRequiredParameter userId error
- DynamoDB Stream in-ordering processing
相关文章
- How to batch_get_item many items at once given a l
- Dynamo DB + In put Item Request how to pass null v
- Is it safe to show the AWS cognito pool ID in my h
- DynamoDB: How can I create a table with nested JSO
- Error: “The security token included in the request
- Read capacity cost of a DynamoDB table scan
- AWS S3 access denied when getting image by url
- Is It possible to change value of Range key in Dyn
ScanIndexForward
is the correct way to get items in descending order by the range key of the table or index you are querying. From the AWS API Reference:Based on the docs for Scan, I conclude that there is no way to Scan in reverse. However, I would say that you are not using DynamoDB correctly if you need to do that. When designing a schema for a database like DyanmoDB you should plan the schema based on your expected queries to ensure that almost all application queries have a good index. Scans are meant more for sys admin operations or for feeding into MapReduce or analytics. "A Scan operation always scans the entire table, then filters out values to provide the desired result, essentially adding the extra step of removing data from the result set." (Query and Scan Performance) That can lead to performance problems and other issues.
Using DynamoDB is fundamentally different from working with a traditional relational database and requires a big change in the way you think about using it. You need to decide whether DynamoDB's advantages of availability in storage and performance, reliability and availability are worth accepting its limitations.
As of now the dynamoDB scan cannot return you sorted results.
You need to use a query with a new global secondary index (GSI) with a hashkey and range field. The trick is to use a hashkey which is assigned the same value for all data in your table.
I recommend making a new field for all data and calling it "Status" and set the value to "OK", or something similar.
Then your query to get all the results sorted would look like this:
The docs for how to write GSI queries are found here: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html#GSI.Querying