An application stores its data in a DynamoDB table.
The application team finds that they have a new access pattern where the application has to perform strongly consistent queries on an attribute that's not the partition key.
How can the team solve this problem?
Click on the arrows to vote for the correct answer
A. B. C. D.Answer: A.
Option A is CORRECT because the requirement is to perform strongly consistent queries on a new partition key.
In this scenario, a new DynamoDB table must be created as GSI only supports eventual consistency.
Option B is incorrect because Global Secondary Indexes do not support strongly consistent reads (but only eventual consistency reads).
Option C is incorrect because Local Secondary Indexes use the same partition key as the base table.
Option D is incorrect because DynamoDB Accelerator is a caching solution for DynamoDB and is not suitable for use in this case.
As a caching solution, it only allows queries on the same partition key as the base table.
Reference:
https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SecondaryIndexes.htmlThe correct answer to the question is B. Create a new GSI.
DynamoDB is a fully managed NoSQL database service provided by AWS. DynamoDB tables are partitioned and replicated automatically to provide scalability, durability, and availability. DynamoDB stores data in partitions, and each partition is identified by a partition key. Queries on the DynamoDB table can be performed based on the partition key or the sort key. When a query is executed on a DynamoDB table, it can be either eventually consistent or strongly consistent.
Strong consistency ensures that a query returns the most recent version of the data. But performing strongly consistent queries in DynamoDB can impact performance and increase latency. In DynamoDB, only the partition key or primary key can be used to perform strongly consistent queries. This means that if the application needs to perform strongly consistent queries on an attribute that is not the partition key, the query will return eventually consistent results.
To solve this problem, the application team can create a new Global Secondary Index (GSI) on the DynamoDB table with the attribute that needs to be queried as the partition key. A GSI is an index with a primary key that is different from the primary key of the table. It enables querying the table using an alternate key, which can be helpful in supporting new access patterns.
Creating a new table (answer A) is not recommended as it will lead to data duplication and synchronization issues. Creating a new Local Secondary Index (LSI) (answer C) is not possible in this case because LSIs share the same partition key as the table. And, creating a DynamoDB Accelerator (DAX) cluster (answer D) is not required as DAX only improves the performance of read-heavy workloads, and it does not impact consistency.