Skip to main content

AWS DVA-C02 Drill: DynamoDB Query Consistency - Choosing the Right Index and Read Model

Jeff Taakey
Author
Jeff Taakey
21+ Year Enterprise Architect | AWS SAA/SAP & Multi-Cloud Expert.

Jeff’s Note
#

Unlike generic exam dumps, ADH analyzes this scenario through the lens of a Real-World Lead Developer.

For DVA-C02 candidates, the confusion often lies in which index type supports strongly consistent reads and how to guarantee the most up-to-date data. In production, this is about knowing exactly when to use Local Secondary Indexes (LSIs) versus Global Secondary Indexes (GSIs) and how DynamoDB’s read consistency models affect your API calls. Let’s drill down.

The Certification Drill (Simulated Question)
#

Scenario
#

BrightBox Tech is building a real-time analytics application that stores user activity events in an Amazon DynamoDB table. The development team needs to efficiently query the table by the primary partition key and filter or sort results with a different sort key. Critically, the application requires the latest data including all recent write operations to those keys.

The Requirement:
#

How should the development team implement the DynamoDB query to retrieve the most recent and strong-consistency-guaranteed data when querying by a different sort key?

The Options
#

  • A) Add a Local Secondary Index (LSI) during table creation. Query the LSI using eventually consistent reads.
  • B) Add a Local Secondary Index (LSI) during table creation. Query the LSI using strongly consistent reads.
  • C) Add a Global Secondary Index (GSI) during table creation. Query the GSI using eventually consistent reads.
  • D) Add a Global Secondary Index (GSI) during table creation. Query the GSI using strongly consistent reads.

Google adsense
#

leave a comment:

Correct Answer
#

B.

Quick Insight: The Developer Imperative
#

Local Secondary Indexes (LSIs) allow strongly consistent reads, unlike GSIs which only support eventually consistent reads. For workloads demanding the absolutely latest data on alternate sort keys, LSIs queried with strong consistency is the correct pattern.

Content Locked: The Expert Analysis
#

You’ve identified the answer. But do you know the implementation details that separate a Junior from a Senior?


The Expert’s Analysis
#

Correct Answer
#

Option B

The Winning Logic
#

  • LSIs must be defined at table creation and share the same partition key as the base table, but can have an alternate sort key.
  • LSIs support strongly consistent reads because they are within the same partition and use the same transactional write operations as the base table.
  • If a developer needs the latest data reflecting all writes, eventually consistent reads risk stale data and should be avoided here.
  • GSIs have different partition keys and physically separate storage, so they only offer eventually consistent reads. Strong consistency is not supported on GSIs.

The Trap (Distractor Analysis):
#

  • Why not A? Using eventually consistent reads risks reading stale data, which violates the requirement for most recent writes.
  • Why not C? GSIs only allow eventually consistent reads, so they cannot guarantee the latest updates.
  • Why not D? GSIs do NOT support strongly consistent reads; this option is invalid technically and would lead to API errors.

The Technical Blueprint
#

# Python example using Boto3 SDK to perform a strongly consistent query on an LSI
import boto3

dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('BrightBoxEvents')

response = table.query(
    KeyConditionExpression=Key('UserId').eq('user-123') & Key('ActivityTime').between('2024-05-01', '2024-05-10'),
    IndexName='ActivityTypeLSI',       # The LSI with alternate sort key on ActivityType
    ConsistentRead=True                # Strongly consistent read is possible on LSI
)

items = response['Items']
print(items)

The Comparative Analysis
#

Option API Complexity Performance Use Case
A Low (LSI creation) Moderate (eventual consistency) Can query by sort key, but stale data possible
B Low (LSI creation) Slightly higher due to consistency Best for recent data and alternate sort key query
C Moderate (GSI creation) High, but eventual consistency Query different partition key patterns, usually for scale
D Invalid—GSI does not support strong consistency - Cannot enforce strong consistency on GSI

Real-World Application (Practitioner Insight)
#

Exam Rule
#

“For the exam, always remember: only LSIs support strongly consistent reads; GSIs do not.”

Real World
#

“In production, developers often pick GSIs for flexible partition/sort key patterns and scalability, tolerating eventual consistency. But when fresh data is required immediately, LSIs are the go-to solution. The catch is LSIs must be defined upfront and share the same partition key.”


(CTA) Stop Guessing, Start Mastering
#


Disclaimer

This is a study note based on simulated scenarios for the AWS DVA-C02 exam.

The DevPro Network: Mission and Founder

A 21-Year Tech Leadership Journey

Jeff Taakey has driven complex systems for over two decades, serving in pivotal roles as an Architect, Technical Director, and startup Co-founder/CTO.

He holds both an MBA degree and a Computer Science Master's degree from an English-speaking university in Hong Kong. His expertise is further backed by multiple international certifications including TOGAF, PMP, ITIL, and AWS SAA.

His experience spans diverse sectors and includes leading large, multidisciplinary teams (up to 86 people). He has also served as a Development Team Lead while cooperating with global teams spanning North America, Europe, and Asia-Pacific. He has spearheaded the design of an industry cloud platform. This work was often conducted within global Fortune 500 environments like IBM, Citi and Panasonic.

Following a recent Master’s degree from an English-speaking university in Hong Kong, he launched this platform to share advanced, practical technical knowledge with the global developer community.


About This Site: AWS.CertDevPro.com


AWS.CertDevPro.com focuses exclusively on mastering the Amazon Web Services ecosystem. We transform raw practice questions into strategic Decision Matrices. Led by Jeff Taakey (MBA & 21-year veteran of IBM/Citi), we provide the exclusive SAA and SAP Master Packs designed to move your cloud expertise from certification-ready to project-ready.