Courseiva
Workload-Specific Database DesignhardMultiple ChoiceObjective-mapped

DBS-C01 ScanIndexForward Practice Question

A social media application uses Amazon DynamoDB with a table that has a partition key of 'user_id' and a sort key of 'post_timestamp'. The application frequently queries for the 10 most recent posts by a specific user. The query pattern uses a 'begins_with' condition on the sort key with a timestamp prefix. Recently, the query latency has increased significantly for users with many posts. Which design change would improve query performance?

⚠ Common exam trap

A common trap is to think that a Local Secondary Index must have a different sort key than the base table. However, DynamoDB allows creating an LSI with the same sort key as the base table; this can be used to provision separate capacity for specific query patterns. Another trap is overlooking that the base table already supports reverse-order queries with ScanIndexForward=false, but creating an LSI can still be beneficial for workload isolation.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Create a local secondary index (LSI) with 'user_id' as partition key and 'post_timestamp' as sort key, and query using reverse order with a limit of 10.

The optimal approach to retrieve the 10 most recent posts for a user is to query the table or an index with the partition key 'user_id' and use ScanIndexForward=false with a Limit of 10. Option A achieves this by creating a Local Secondary Index (LSI) with the same partition key and sort key as the base table. While the base table itself can be queried in reverse order, creating an LSI dedicated to this query pattern can improve performance by offloading reads from the base table index, reducing contention and ensuring fast consistent reads. The LSI can be provisioned with its own read capacity to handle the frequent queries for the most recent posts per user, thus improving overall query performance. Options B, C, and D do not effectively address the specific requirement of per-user recent posts. Option B (DAX) may reduce latency but does not fix the underlying inefficient query pattern (scanning many items per user). Option C (GSI with timestamp as partition key) would allow querying posts globally by time, not per user. Option D (changing partition key to post_id) would break the ability to query all posts by a user. Therefore, Option A is the correct design change.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Create a local secondary index (LSI) with 'user_id' as partition key and 'post_timestamp' as sort key, and query using reverse order with a limit of 10.

    Why this is correct

    Creating an LSI with 'user_id' as partition key and 'post_timestamp' as sort key allows querying in reverse order with a limit of 10, efficiently retrieving the most recent posts for a user.

  • Enable DynamoDB Accelerator (DAX) to cache the query results.

    Why it's wrong here

    DAX caches results but does not optimize the underlying query pattern; it may reduce latency for repeated queries but does not address the inefficient 'begins_with' condition.

  • Create a global secondary index (GSI) with 'post_timestamp' as partition key and 'user_id' as sort key.

    Why it's wrong here

    A GSI with 'post_timestamp' as partition key queries globally by timestamp, not per user, so it cannot efficiently retrieve the 10 most recent posts for a specific user.

  • Change the table's partition key to 'post_id' to distribute data more evenly.

    Why it's wrong here

    Changing the partition key to 'post_id' would break the existing query pattern and not improve performance for the common query of recent posts by user.

About these practice questions

One of 1,663 original DBS-C01 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This DBS-C01 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DBS-C01 exam.