Soru

Zorluk: OrtaData Store Operations with Amazon DynamoDB

A developer is implementing a news publishing application that stores article metadata in an Amazon DynamoDB table. The base table uses `ArticleID` as the partition key and `Category` as the sort key. The application needs to frequently retrieve all articles written by a specific author, sorted by their publication date, to display on the author's biography page. The author's identifier is stored in an attribute named `AuthorID`, and the publication date is stored in `PublishDate`.

Which approach should the developer implement to retrieve this data in the most cost-effective and performant manner?

  1. Create a Global Secondary Index (GSI) with AuthorID as the partition key and PublishDate as the sort key, then use the Query API operation on the GSI.Cevap
  2. B
    Perform a Scan API operation on the base table using a FilterExpression to filter results by AuthorID and PublishDate.
  3. C
    Increase the provisioned read capacity units (RCUs) on the base table and perform a full scan to prevent performance degradation.
  4. D
    Initialize the AWS SDK client using hardcoded IAM access keys to bypass read capacity limits and access the table partitions directly.

Cevap

Create a Global Secondary Index (GSI) with AuthorID as the partition key and PublishDate as the sort key, then use the Query API operation on the GSI.
Creating a Global Secondary Index (GSI) with AuthorID as the partition key and PublishDate as the sort key enables the application to perform highly efficient Query operations. Since a Query operation only reads the items that match the specified partition key value, this approach minimizes Read Capacity Unit (RCU) consumption and retrieval latency.

Adım Adım Çözüm

1
Analyze the access pattern and base table schema.
The application needs to search by AuthorID (which is not the partition key of the base table) and sort by PublishDate (which is not the sort key of the base table).
This shows that querying the base table directly using the primary keys is not possible for this access pattern.
2
Select the appropriate DynamoDB indexing strategy to support the access pattern.
Create a Global Secondary Index (GSI) where the partition key is AuthorID and the sort key is PublishDate.
A GSI allows querying across the entire table using a partition key and sort key that are different from the base table's primary keys.
3
Choose the most efficient API call for retrieving the data from the index.
Use the Query API operation on the GSI specifying the AuthorID in the key condition expression.
The Query operation only consumes Read Capacity Units (RCUs) for the items actually returned, making it highly efficient compared to scanning the entire table.

Anahtar Kavram

Efficient data retrieval in DynamoDB using Global Secondary Indexes (GSIs) and the Query API operation to avoid expensive Scan operations.
Bu soruyu puanla