DVA-C02 Query with ScanIndexForward Practice Question
A developer is using Amazon DynamoDB for a gaming leaderboard. The table has a sort key of 'score' (Number). The developer wants to retrieve the top 10 players. Which TWO operations can achieve this? (Choose TWO.)
⚠ Common exam trap
The pitfall is that candidates assume Query with ScanIndexForward=false and Limit=10 works globally across all partitions, but it only applies within a single partition key. However, if the table uses a constant partition key (common for leaderboards), it becomes a valid solution. Always consider the table design when evaluating Query vs. Scan.
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
✓
Scan and sort results client-side, then take first 10
Scanning all items and sorting them client-side by score descending gives the global top 10, regardless of partition keys. Option E is correct if the table is designed with a single partition key (e.g., a constant value like 'Leaderboard'), because a Query with ScanIndexForward=false and Limit=10 then retrieves the top 10 items from that partition efficiently. Options A, C, and D are incorrect because they cannot return the top 10 items sorted globally.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
TransactGetItems
Why it's wrong here
TransactGetItems allows for the atomic retrieval of multiple items, ensuring that either all requested items are returned or none are. However, similar to BatchGetItem, it requires specifying the exact primary keys of the items to be retrieved. This operation provides no functionality for sorting items by an attribute like score, nor does it offer a mechanism to identify the top N items based on a condition, rendering it unsuitable for determining a leaderboard's top 10.
- ✓
Scan and sort results client-side, then take first 10
Why this is correct
A Scan operation reads every single item in the entire DynamoDB table or a secondary index, which can then be sorted client-side by the score attribute in descending order, with the first 10 items taken. While this method technically yields the correct top 10 results, it is highly inefficient and expensive for large tables. It consumes significant read capacity units (RCUs) and network bandwidth by transferring all data, making it impractical for a production leaderboard.
- ✗
BatchGetItem
Why it's wrong here
BatchGetItem is designed to retrieve multiple items from one or more tables based on a collection of known primary keys. It does not provide any sorting or filtering capabilities to identify items based on an attribute like a score. Therefore, it cannot be used to discover the top 10 items in a leaderboard without already knowing the exact primary keys of those specific top-scoring players.
- ✗
GetItem
Why it's wrong here
GetItem is used to retrieve a single item from a table when its complete primary key (partition key and sort key, if applicable) is precisely known. This operation is fundamentally unsuitable for a leaderboard scenario because it cannot retrieve multiple items, nor does it offer any mechanism to sort items by a score attribute or apply a limit to find the top N entries.
- ✓
Query with ScanIndexForward set to false and Limit set to 10
Why this is correct
This is an efficient and correct approach, assuming the DynamoDB table is designed with a single partition key (e.g., 'LeaderboardID' with a static value) and the player's score as the sort key. A Query operation targets this specific partition key, and setting ScanIndexForward to false ensures results are ordered by score in descending order. The Limit of 10 then efficiently retrieves only the top 10 highest-scoring items within that partition without scanning unnecessary data.
Go deeper
Related to this question
About these practice questions
One of 724 original DVA-C02 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 →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DVA-C02 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 DVA-C02 exam.