Soru

Zorluk: KolayData Store Operations with Amazon DynamoDB

A developer is building a backend for a recipe sharing application. The application needs to retrieve a single recipe's details from an Amazon DynamoDB table by providing the exact `RecipeId` (which is the table's partition key). Which approach should the developer use to retrieve this item most efficiently with the lowest latency and read capacity unit (RCU) consumption?

  1. A
    Perform a Scan operation with a filter expression matching the RecipeId.
  2. Perform a GetItem operation using the specific RecipeId.Cevap
  3. C
    Perform a GetItem operation, but hardcode the AWS access keys in the client initialization to bypass default IAM credential lookup.
  4. D
    Perform a Query operation and scale up the table's overall provisioned read capacity to avoid hot partition throttling.

Cevap

Perform a GetItem operation using the specific RecipeId.
The correct approach is to perform a GetItem operation using the specific RecipeId. In Amazon DynamoDB, GetItem is the most efficient method for retrieving a single item when the full primary key (the partition key in this case) is known. It directly retrieves the item without scanning other data, minimizing latency and RCU consumption.

Adım Adım Çözüm

1
Identify the primary key structure and request details.
The application needs to retrieve a single item using its partition key (RecipeId).
Understanding the key structure helps choose the most specific and optimized API operation.
2
Compare candidate operations (GetItem, Query, Scan).
GetItem is designed for single-item lookups, Query is for multiple items with the same partition key, and Scan evaluates all items in the table.
Choosing the operation that accesses the fewest items minimizes latency and cost.
3
Select GetItem as the optimal API call.
GetItem retrieves the exact item directly using the primary key, consuming 1 strongly consistent read or 0.5 eventually consistent read capacity units.
This achieves the lowest latency and resource consumption.

Anahtar Kavram

Selecting the most efficient DynamoDB operation for single-item retrieval using a primary key.
Bu soruyu puanla