Soru

Zorluk: OrtaData Store Operations with Amazon DynamoDB

A developer is writing an AWS Lambda function that retrieves the 55 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.)

  1. Set the `ScanIndexForward` parameter to `false` to reverse the sort order of the query results.Cevap
  2. B
    Use a `FilterExpression` instead of a key condition expression to filter the query results to the 55 most recent orders.
  3. C
    Perform a `Scan` operation on the table and use a `ProjectionExpression` to retrieve only the required items.
  4. Set the `Limit` parameter to `55` to restrict the number of items evaluated and returned by the query.Cevap
  5. E
    Set 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 `55` 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 `55`. 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 55 items, minimizing the Read Capacity Units (RCUs) consumed.

Adım Adım Çözüm

1
Reverse the default sort key order in the Query request.
By setting `ScanIndexForward` to `false`, DynamoDB reads the sort key (`OrderDate`) in descending order, starting with the most recent items.
This positions the most recent orders at the beginning of the evaluation set.
2
Apply a limit parameter to restrict the scope of the evaluation.
By setting the `Limit` parameter to `55`, DynamoDB stops reading records as soon as 55 items are evaluated and returned.
This prevents DynamoDB from reading the rest of the customer's partition, saving Read Capacity Units (RCUs).
3
Avoid post-query filter expressions or scan operations.
Using key condition expressions instead of filter expressions ensures only the target customer data is read, avoiding scanned item overhead.
Filter expressions and scan operations consume RCUs on evaluated items that are subsequently discarded.

Anahtar Kavram

Optimizing read query operations in DynamoDB using ScanIndexForward and Limit settings
Tahmini Süre:1m 30s
Bu soruyu puanla