Soru

Zorluk: OrtaData Store Operations with Amazon DynamoDB

A developer is building a customer support ticketing portal. The application stores tickets in an Amazon DynamoDB table with `CustomerID` as the partition key and `TicketID` as the sort key. The developer needs to implement a dashboard view that displays all tickets with a status of `Open` across all customers, sorted by the date they were created. Which strategy should the developer use to retrieve this data with the lowest latency and minimal Read Capacity Unit (RCU) consumption?

  1. Create a Global Secondary Index (GSI) using Status as the partition key and CreatedAt as the sort key, and then perform a Query operation on the GSI.Cevap
  2. B
    Perform a Scan operation on the base table using a FilterExpression to retrieve only the items where the Status attribute is equal to Open.
  3. C
    Increase the provisioned read capacity units (RCUs) on the base table and use a Scan operation to handle the queries without throttling.
  4. D
    Initialize the AWS SDK client with hardcoded administrator credentials in the application source code to perform parallel scans.

Cevap

Create a Global Secondary Index (GSI) using Status as the partition key and CreatedAt as the sort key, and then perform a Query operation on the GSI.
Creating a Global Secondary Index (GSI) with Status as the partition key and CreatedAt as the sort key allows the application to query all open tickets across all customers. A Query operation on the GSI reads only the items that match the key condition, minimizing Read Capacity Unit (RCU) consumption and reducing latency.

Adım Adım Çözüm

1
Analyze the query requirement to determine if the base table keys can support it.
The query needs to retrieve records by Status across all CustomerIDs, but the base table's partition key is CustomerID, making a Query on the base table impossible for this access pattern.
Since the partition key is CustomerID, we can only query within a single customer partition at a time.
2
Evaluate the secondary index options to enable queries across all partitions.
A Global Secondary Index (GSI) can be created with Status as the partition key and CreatedAt as the sort key.
GSIs allow query operations across all base table partitions by defining a new partition key.
3
Determine the optimal operation to run on the secondary index.
Run a Query operation against the GSI targeting Status = 'Open'.
Query operations are highly efficient because they only read items that match the key condition, minimizing RCU usage compared to a full Scan.

Anahtar Kavram

Using a Global Secondary Index (GSI) to support query access patterns across all partition keys of a base DynamoDB table.
Tahmini Süre:1m 30s
Bu soruyu puanla