A developer is building a logistics tracking application that stores package delivery status updates in an Amazon DynamoDB table. The table has a partition key of `PackageID` and a sort key of `StatusTimestamp`. The application needs to retrieve all delivery status updates for a specific `PackageID` that occurred within the last hours. The results must be returned starting with the most recent update first.
Which two actions should the developer take to meet these requirements with the lowest latency and minimal Read Capacity Unit (RCU) consumption? (Select TWO.)
- Use the `Query` API operation with a key condition expression specifying the `PackageID` and a range comparison on `StatusTimestamp`.Cevap
- Set the `ScanIndexForward` parameter to `false` in the API request.Cevap
- CUse the `Scan` API operation with a filter expression specifying the `PackageID` and `StatusTimestamp`.
- DHardcode AWS credentials directly in the application's SDK client configuration to minimize authorization latency.
- EIncrease the provisioned read capacity units (RCUs) for the table to prevent throttling when sorting the retrieved dataset.
Cevap
Use the `Query` API operation with a key condition expression on the partition key and sort key, and set the `ScanIndexForward` parameter to `false` in the API request.
To retrieve items sharing the same partition key (`PackageID`) efficiently, the `Query` API operation should be used. The query can filter results by the sort key (`StatusTimestamp`) directly in the key condition expression, which consumes Read Capacity Units (RCUs) only for the items that match the criteria. By default, DynamoDB returns query results in ascending order of the sort key. Setting the `ScanIndexForward` parameter to `false` reverses this order, returning the most recent updates first.
Adım Adım Çözüm
Anahtar Kavram
Optimizing read operations in Amazon DynamoDB using Query instead of Scan and controlling sort order via ScanIndexForward.