C100DEV Indexing Practice Question
A developer maintains a collection of sensor readings. Queries almost always filter on `status` and then sort by `timestamp` descending. The current index is { status: 1, timestamp: 1 }. The developer observes that the query planner selects a COLLSCAN even though the index covers both fields. Which index change should be made to allow an efficient index scan for this query?
⚠ Common exam trap
The trap here is assuming any compound index containing both fields will work, when the field order and sort direction must exactly match the equality-then-sort pattern.
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 new index { status: 1, timestamp: -1 } and drop the existing index.
The query combines an equality predicate on `status` with a descending sort on `timestamp`. Following equality-sort-range ordering, the equality field belongs first and the sort field must match the query direction, giving `{ status: 1, timestamp: -1 }`. That lets the planner walk the index in the requested order without a blocking sort, which is why the reversed or split alternatives fail.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Add a separate index { timestamp: -1 } and keep the existing compound index.
Why it's wrong here
A standalone `timestamp` index cannot serve the equality predicate on `status` as the leading field, so the planner must still scan many documents and then filter. Keeping the original compound index alongside it does not change the fact that neither index matches the equality-then-sort pattern, so the inefficiency persists.
- ✓
Create a new index { status: 1, timestamp: -1 } and drop the existing index.
Why this is correct
With equality on `status` and a descending sort on `timestamp`, the index must place the equality field first and the sort field in the matching direction. `{ status: 1, timestamp: -1 }` satisfies both, so the planner can perform an index scan that returns documents already ordered, avoiding a blocking sort and a collection scan.
- ✗
Create a new index { timestamp: -1, status: 1 } and drop the existing index.
Why it's wrong here
This reverses the equality field and the sort field, violating the ESR guidance for this access pattern. Because `status` is an equality predicate, it should lead the index; with `timestamp` first the planner cannot use the index to satisfy both the filter and the descending sort efficiently, so a collection scan or in-memory sort remains likely.
- ✗
Create a hashed index on `status` combined with `timestamp` to improve selectivity.
Why it's wrong here
Hashed indexes support only equality matches and cannot satisfy range or sort operations such as an ordered scan on `timestamp`. A hashed `status` component would force the planner to fetch and sort results in memory, so it cannot replace the compound index that the equality-plus-descending-sort query requires.
About these practice questions
This C100DEV question is part of Courseiva's 259-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official MongoDB exam blueprint
This C100DEV practice question is part of Courseiva's free MongoDB 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 C100DEV exam.