Soru

Zorluk: OrtaData Store Operations with Amazon DynamoDB

A developer is building a movie ticket booking platform. The ticket reservation details are stored in an Amazon DynamoDB table with ReservationIDReservationID as the partition key. To generate real-time metrics, the application must frequently retrieve all reservations associated with a specific ShowIDShowID. The query must be highly performant and cost-effective as the database grows.

Which solution meets these requirements with the lowest latency and resource consumption?

  1. Create a Global Secondary Index (GSI) with ShowIDShowID as the partition key, and perform a Query operation on the GSI.Cevap
  2. B
    Perform a Scan operation on the base table using a FilterExpression on the ShowIDShowID attribute to retrieve the matching reservations.
  3. C
    Initialize the AWS SDK client by hardcoding temporary credentials in the application source code to perform parallel Scan operations on the base table.
  4. D
    Increase the provisioned Read Capacity Units (RCUs) on the base table to resolve any throughput throttling, and continue to run Scan operations to filter by ShowIDShowID.

Cevap

Create a Global Secondary Index (GSI) with the target query attribute as the partition key, and perform a Query operation on the GSI.
Creating a Global Secondary Index (GSI) with the target query attribute as the partition key is the correct approach. It enables the application to use the Query API instead of Scan, ensuring that only the items associated with the target attribute value are read. This consumes minimal Read Capacity Units (RCUs) and executes with low, predictable latency regardless of the table's overall size.

Adım Adım Çözüm

1
Analyze the table primary key structure and retrieval requirements.
The base table uses a simple primary key with a partition key of ReservationIDReservationID. Querying by ShowIDShowID directly on the base table is not supported because ShowIDShowID is a non-key attribute.
DynamoDB only allows Query operations on the primary key attributes (partition key and optional sort key) of the table or an index.
2
Determine the optimal indexing strategy for the non-key attribute.
Create a Global Secondary Index (GSI) with ShowIDShowID as the partition key.
Since the partition key of the base table is different from the search attribute, a GSI is required to allow direct querying on the new partition key.
3
Select the correct API operation for retrieval.
Perform a Query operation against the GSI using the specific ShowIDShowID.
A Query operation is much more efficient than a Scan because it only reads the items matching the key value, reducing Read Capacity Unit (RCU) consumption and latency.

Anahtar Kavram

Using Global Secondary Indexes (GSIs) and Query operations to efficiently retrieve data from Amazon DynamoDB tables on non-primary key attributes.
Bu soruyu puanla