Your application stores items in DynamoDB and you need to query by the table's partition key combined with an alternate sort key value, and you must read the most recent data including recent writes. How should you design the query?
Choose an answer
Tap an option to check your answer.
Correct answer: Create a local secondary index (LSI) when creating the table, and query the LSI using strongly consistent reads..
Why this is the answer
The correct approach is to create a local secondary index (LSI) and query it using strongly consistent reads. An LSI shares the same partition key as the base table but allows for a different sort key, enabling queries on alternate sort key values within the same partition. Strongly consistent reads ensure that you always retrieve the most up-to-date data, including recent writes, which is a key requirement. Global secondary indexes (GSIs) are incorrect because they have a different partition key from the base table, making them unsuitable for queries that combine the base table's partition key with an alternate sort key. Additionally, GSIs only support eventually consistent reads, which would not meet the requirement for reading the most recent data. Eventually consistent reads on an LSI would also fail to meet the strong consistency requirement.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed