A developer is building a workflow management application that tracks task history in an Amazon DynamoDB table. The table has as the partition key and as the sort key. The application needs to retrieve the single most recent update for a specific task to display on a dashboard. Which DynamoDB API configuration should the developer use to retrieve this item with the lowest latency and minimal Read Capacity Unit (RCU) consumption?
- AInvoke the Scan API with a filter expression for the attribute, sort the returned array by in the application code, and select the first item.
- BInitialize the AWS SDK DynamoDB client by passing hardcoded IAM access keys directly into the client constructor, and invoke the GetItem API using only the attribute.
- Invoke the Query API with a key condition expression for the , set the parameter to false, and set the parameter to .Cevap
- DInvoke the Query API to retrieve all updates for a given , and if a ProvisionedThroughputExceededException is thrown, resolve it by increasing the overall provisioned Read Capacity Units (RCUs) for the table.
Cevap
Invoke the Query API with a key condition expression for the partition key, set ScanIndexForward to false, and set the Limit parameter to 1.
To retrieve the latest item under a specific partition key in a table with a composite primary key, the most efficient method is to perform a `Query` operation. By specifying the partition key in the key condition expression, setting `ScanIndexForward` to `false` (which reverses the sort key order to descending), and setting `Limit` to , DynamoDB only reads and returns the single most recent item. This minimizes the read capacity units (RCUs) consumed.
Adım Adım Çözüm
Anahtar Kavram
Optimizing read operations on composite keys using the DynamoDB Query API with ScanIndexForward and Limit
Tahmini Süre:1m 30s