Skip to main content

AWS DVA-C02 Drill: DynamoDB Query Patterns - Partial Matching with GSIs

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 how to efficiently implement partial match queries on DynamoDB indexes without table redesigns. In production, this is about knowing exactly which type of secondary index supports your query pattern and how to use condition operators like begins_with correctly. Let’s drill down.

The Certification Drill (Simulated Question)
#

Scenario
#

A software team at a logistics startup has a DynamoDB table that stores driver contact details. The table’s partition key is the driver’s unique license_number, and items include attributes like region, driver_name, and vehicle_type. They have a Lambda function to power a search feature: whenever a user types a character into a “region” search box, the Lambda executes. The goal is to return partial matches on the license_number attribute for drivers in the specified region. The company does not want to modify or recreate the existing DynamoDB table.

The Requirement:
#

Enable efficient, partial-match searches on the license_number attribute filtered by region without rebuilding the table.

The Options
#

  • A) Add a global secondary index (GSI) on the DynamoDB table with region as the partition key and license_number as the sort key. Use a query operation on the GSI with a begins_with condition on the license_number attribute.
  • B) Add a global secondary index (GSI) on the table with license_number as the partition key and region as the sort key. Query this GSI using begins_with on license_number.
  • C) Add a local secondary index (LSI) on the table with region as the partition key and license_number as the sort key. Query this LSI with begins_with on license_number.
  • D) Add a local secondary index (LSI) on the table with vehicle_type as the partition key and license_number as the sort key. Query this LSI using begins_with on license_number.

Google adsense
#

leave a comment:

Correct Answer
#

A

Quick Insight: The Developer Imperative
#

For developers focused on API efficiency and Lambda integration, the key is understanding DynamoDB secondary index types and how they relate to partition and sort keys for query flexibility.
Global secondary indexes (GSIs) can have different partition keys than the base table—essential to filter by region first, then perform partial license_number matching using begins_with on the sort key.

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 A

The Winning Logic
#

  • GSI with region as partition key and license_number as sort key allows you to efficiently query all drivers from a specific region first.
  • Using the begins_with operator on the sort key lets you do partial matching on license_number values.
  • Since GSIs can be added without rebuilding the table and can use different keys than the base table, this fits the requirement perfectly.
  • The Lambda function can then query the GSI with a condition expression like region = :regionVal AND begins_with(license_number, :input) for incremental search.

The Trap (Distractor Analysis):
#

  • Option B: Inverts the keys, using license_number as partition key. You cannot do range queries (begins_with) on partition keys, so partial matching on license_number is impossible this way.
  • Option C and D: Local secondary indexes (LSIs) require the same partition key as the base table (license_number), so having region or vehicle_type as partition key is invalid. You cannot add LSIs on different partition keys. Also, LSIs can only be created at table creation, conflicting with the “do not recreate table” requirement.

The Technical Blueprint
#

Relevant AWS CLI Command to Create the GSI
#

aws dynamodb update-table \
    --table-name DriverContactInfo \
    --attribute-definitions AttributeName=region,AttributeType=S AttributeName=license_number,AttributeType=S \
    --global-secondary-index-updates '[{"Create":{"IndexName":"RegionLicenseIndex","KeySchema":[{"AttributeName":"region","KeyType":"HASH"},{"AttributeName":"license_number","KeyType":"RANGE"}],"Projection":{"ProjectionType":"ALL"},"ProvisionedThroughput":{"ReadCapacityUnits":5,"WriteCapacityUnits":5}}}]'

Sample Query Using AWS SDK (Python boto3)
#

response = dynamodb_client.query(
    TableName='DriverContactInfo',
    IndexName='RegionLicenseIndex',
    KeyConditionExpression='region = :r AND begins_with(license_number, :ln)',
    ExpressionAttributeValues={
        ':r': {'S': user_selected_region},
        ':ln': {'S': partial_license_number_input}
    }
)
items = response['Items']

The Comparative Analysis
#

Option Index Type Partition Key Sort Key Query Flexibility Compliance with Requirement Notes
A Global Secondary Index region license_number Supports begins_with on sort key Allowed without table recreation Correct choice
B Global Secondary Index license_number region Cannot partial search on partition key Fails partial matching requirement Incorrect key design
C Local Secondary Index region (invalid) license_number Invalid partition key for LSI LSI requires original partition key Invalid index creation
D Local Secondary Index vehicle_type (invalid) license_number Invalid partition key for LSI LSI requires original partition key Invalid index creation

Real-World Application (Practitioner Insight)
#

Exam Rule
#

For the exam, always pick GSIs when you need query flexibility with different partition keys—especially for filtering and partial matches on sort keys.

Real World
#

In a real-world environment, you might also consider integrating Amazon Elasticsearch or OpenSearch Service for richer full-text search capabilities. However, for the exam and many workloads, efficient GSI design meets the requirement perfectly at lower operational cost.


(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.