Soru

Zorluk: OrtaData Store Operations with Amazon DynamoDB

A developer is building a classroom management application that tracks student assignment submissions. The application stores submission records in an Amazon DynamoDB table. The base table has a partition key of `ClassId` and a sort key of `StudentId_AssignmentId`. The developer needs to retrieve all submissions for a specific class that were submitted after a certain date, sorted by submission date, while minimizing Read Capacity Unit (RCU) consumption.

Which TWO actions should the developer take to meet these requirements? (Select TWO.)

  1. Create a local secondary index (LSI) with ClassId as the partition key and SubmissionTimestamp as the sort key.Cevap
  2. Use the Query operation on the local secondary index (LSI) with a key condition expression for ClassId and SubmissionTimestamp.Cevap
  3. C
    Use the Scan operation on the base table with a filter expression on the SubmissionTimestamp attribute.
  4. D
    Use the Query operation on the base table and apply a filter expression on SubmissionTimestamp.
  5. E
    Increase the provisioned read capacity units (RCUs) of the base table to prevent read throughput exceptions during the retrieval process.

Cevap

To retrieve submissions efficiently while minimizing RCU consumption, the developer should create a local secondary index (LSI) with ClassId as the partition key and SubmissionTimestamp as the sort key, and then use the Query operation on this index with a key condition expression specifying both ClassId and SubmissionTimestamp.
Creating a local secondary index (LSI) sharing the same partition key (ClassId) but using SubmissionTimestamp as the sort key allows the application to perform a Query operation. By querying the LSI with a key condition expression for the class and the timestamp range, DynamoDB only reads the matching items, minimizing the Read Capacity Units (RCUs) consumed and returning the results pre-sorted by the sort key.

Adım Adım Çözüm

1
Analyze the access pattern and base table schema.
The base table partition key is ClassId and the sort key is StudentId_AssignmentId. Querying by ClassId alone requires reading all student assignments for that class, which is inefficient when only filtering by date.
To minimize RCU consumption, we must ensure we only read the records that match our filter criteria.
2
Identify the indexing strategy to support the date query.
Since we need to query within a specific ClassId (the partition key), we can create a Local Secondary Index (LSI) with ClassId as the partition key and SubmissionTimestamp as the sort key.
An LSI allows us to use the same partition key as the base table but sort and query by a different attribute.
3
Select the appropriate DynamoDB operation to retrieve the data.
Perform a Query operation on the LSI using a key condition expression specifying ClassId and a comparison operator on SubmissionTimestamp.
Query operations on indexes with key condition expressions only read and consume RCUs for the items that meet the criteria, unlike Scan operations or post-query filters.

Anahtar Kavram

Optimizing DynamoDB retrieval using Local Secondary Indexes (LSI) and Query operations instead of Scan or filter expressions on non-key attributes.
Tahmini Süre:1m 30s
Bu soruyu puanla