Question

Difficulty: EasyData Store Operations with Amazon DynamoDB

A developer is building a mobile application that stores user profile information in an Amazon DynamoDB table. The table uses UserId as the partition key. The developer needs to retrieve the profile details of a specific user with a known UserId in the most cost-effective and low-latency way possible.

Which two API operations or practices should the developer use to achieve this?

  1. Perform a GetItem API call specifying the UserId primary key to retrieve the exact user profile.Answer
  2. Perform a Query API call using a key condition expression to search for the specific UserId.Answer
  3. C
    Perform a Scan API call with a filter expression matching the specific UserId to filter the results.
  4. D
    Perform a Scan API call to retrieve the entire table, then filter the target UserId in application memory.
  5. E
    Hardcode the AWS access key and secret key in the client configuration to eliminate IAM role assumption latency.

Answer

Retrieve the item using either the GetItem operation targeting the primary key, or the Query operation with a key condition expression matching the partition key.
The correct approach involves retrieving data directly by the partition key to minimize read capacity consumption and latency. The GetItem operation retrieves a single item based on its primary key and is the most efficient way to access a single record. Alternatively, the Query operation uses a key condition expression to retrieve items that share the same partition key, which is also highly efficient because it only reads the partition containing the matching partition key.

Step-by-Step Solution

1
Identify the primary key structure of the table.
The table partition key is UserId.
Understanding the key schema helps determine which API operations can perform key-based lookups rather than full table scans.
2
Select operations that perform direct lookups on the partition key.
GetItem and Query operations are selected.
GetItem retrieves a specific item by its primary key. Query allows searching items matching a key condition expression on the partition key. Both operations target specific partitions directly.
3
Avoid operations that scan the entire table.
Scan operations are rejected.
Scan operations read all items in the table, which is inefficient, costly, and leads to high latency.

Key Concept

Efficient DynamoDB retrieval using primary keys (GetItem and Query) versus inefficient scans.
Rate this question