C100DEV Indexing Practice Question
A retail application queries an `orders` collection with a filter on `status` and `customerId`, and a sort on `orderDate`. The query shape is: `db.orders.find({ status: "shipped", customerId: 12345 }).sort({ orderDate: -1 })`. The collection has no indexes other than the default `_id` index. Which index should be created to best support this query according to the ESR guideline?
⚠ Common exam trap
The trap here is assuming that the sort field should come first because sorting is expensive, when the ESR guideline actually places equality fields before the sort field.
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, customerId: 1, orderDate: -1 }
The ESR guideline orders compound index fields as Equality, Sort, Range. The query has equality predicates on `status` and `customerId` and a sort on `orderDate`. Placing both equality fields first and the sort field last, as in `{ status: 1, customerId: 1, orderDate: -1 }`, lets the index serve the equality matches and provide sorted output without an in-memory sort.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
{ status: 1, orderDate: -1, customerId: 1 }
Why it's wrong here
Although `status` is an equality field and is first, `orderDate` (the sort field) appears before `customerId` (another equality field). The ESR guideline requires equality fields to precede the sort field. This ordering prevents the index from using `customerId` as an equality prefix before sorting, which can lead to less efficient execution.
- ✓
{ status: 1, customerId: 1, orderDate: -1 }
Why this is correct
The ESR guideline orders index fields as Equality, Sort, Range. Here `status` and `customerId` are equality predicates and `orderDate` is used for sorting. Placing the equality fields first and the sort field last allows the index to satisfy the equality matches and then provide sorted results without an in-memory sort, making this the optimal compound index.
- ✗
{ customerId: 1, orderDate: -1, status: 1 }
Why it's wrong here
This index places one equality field, then the sort field, then another equality field. The ESR guideline requires all equality fields before the sort field. With `status` after `orderDate`, the index cannot use both equality predicates as a contiguous prefix before sorting, reducing efficiency and potentially forcing an in-memory sort.
- ✗
{ orderDate: -1, status: 1, customerId: 1 }
Why it's wrong here
This index places the sort field first, followed by equality fields. The ESR guideline recommends equality fields before sort fields. With `orderDate` leading, the index cannot efficiently use both equality predicates before sorting, and the sort may not be fully supported by the index prefix for the given equality matches.
About these practice questions
Courseiva writes every C100DEV question from scratch — 259 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.