C100DEV Indexing Practice Question
You are optimizing a query: db.orders.find({ status: 'urgent', amount: { $gt: 500 } }).sort({ order_date: -1 }). According to the ESR (Equality, Sort, Range) rule, what is the ideal index for this query?
⚠ Common exam trap
Candidates often place the range filter field before the sort field, which prevents the index from being used to satisfy the sort, leading to slow in-memory sorting operations.
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
✓
{ status: 1, order_date: -1, amount: 1 }
The ESR rule is a best practice for ordering fields in a compound index to maximize efficiency. Equality matches should come first to narrow the result set, followed by the Sort field to allow the index to provide the requested order, and finally the Range filter. This order minimizes the number of index keys scanned and avoids in-memory sorts.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
{ amount: 1, order_date: -1, status: 1 }
Why it's wrong here
This index places the Range field ('amount') before the Equality and Sort fields. This is inefficient because once a range is applied, the subsequent fields in the index cannot be used for sorting or further equality filtering without scanning many unnecessary keys, violating the ESR performance principles.
- ✗
{ order_date: -1, status: 1, amount: 1 }
Why it's wrong here
Placing the Sort field before the Equality field is suboptimal. If 'status' is not the first field, the database cannot jump to the 'urgent' documents and then read them in 'order_date' sequence. It would instead have to scan all 'order_date' entries and filter for 'status' manually.
- ✓
{ status: 1, order_date: -1, amount: 1 }
Why this is correct
This follows the ESR rule perfectly. 'status' is an equality match, 'order_date' is the sort field, and 'amount' is a range filter. By ordering them this way, MongoDB can filter by status, then use the index's natural order for the sort, and finally apply the range filter on the remaining entries.
- ✗
{ status: 1, amount: 1, order_date: -1 }
Why it's wrong here
In this configuration, the Range field 'amount' comes before the Sort field 'order_date'. When a range filter is encountered in an index scan, any subsequent fields cannot be used for sorting. This would force MongoDB to perform an expensive in-memory sort after filtering the documents by status and amount.
About these practice questions
One of 259 original C100DEV 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 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.