A developer is writing an AWS Lambda function that retrieves the most recent orders for a specific customer from an Amazon DynamoDB table named `Orders`. The table has a partition key of `CustomerID` and a sort key of `OrderDate`, and contains millions of records.
Which two options should the developer configure in the DynamoDB API request to retrieve the required data in the most resource-efficient manner? (Choose two.)
- Set the `ScanIndexForward` parameter to `false` to reverse the sort order of the query results.Cevap
- BUse a `FilterExpression` instead of a key condition expression to filter the query results to the most recent orders.
- CPerform a `Scan` operation on the table and use a `ProjectionExpression` to retrieve only the required items.
- Set the `Limit` parameter to `` to restrict the number of items evaluated and returned by the query.Cevap
- ESet the `ConsistentRead` parameter to `true` to ensure the query returns the latest ordered items at a lower Read Capacity Unit (RCU) cost.
Cevap
To retrieve the five most recent orders efficiently, the developer should set the `ScanIndexForward` parameter to `false` to reverse the sort key order and set the `Limit` parameter to `` to restrict the number of items evaluated and returned.
The correct configuration combines reversing the sort key order using `ScanIndexForward` set to `false` with restricting the evaluations using the `Limit` parameter set to ``. This pattern allows DynamoDB to target the specific partition key, read the items in descending order of the sort key, and stop immediately after finding the first items, minimizing the Read Capacity Units (RCUs) consumed.
Adım Adım Çözüm
Anahtar Kavram
Optimizing read query operations in DynamoDB using ScanIndexForward and Limit settings
Tahmini Süre:1m 30s