C100DBA Indexing and Performance Practice Question
An application frequently queries a large collection using two fields: 'category' (equality) and 'timestamp' (range). Which index strategy provides the most efficient execution plan?
⚠ Common exam trap
Candidates often put the range field before the equality field, violating the ESR rule. This leads to inefficient index usage and slower query performance on large datasets.
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
✓
{ category: 1, timestamp: 1 }
The ESR (Equality, Sort, Range) rule dictates that equality fields should come first in a compound index, followed by sort fields, and finally range fields. By placing 'category' first, MongoDB eliminates most irrelevant documents immediately. The 'timestamp' field follows, allowing the engine to leverage the index for range filtering. This minimizes memory usage and prevents costly full collection scans, which is critical for maintaining performance as data volume scales.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
{ timestamp: 1, category: 1 }
Why it's wrong here
Placing the range field before the equality field forces the database to scan a larger portion of the index. This violates the ESR rule, preventing the query optimizer from effectively pruning the search space, which leads to higher disk I/O and increased latency during execution.
- ✗
{ category: 1 }
Why it's wrong here
An index on only the equality field helps narrow down the category, but the database must still perform a secondary scan on the entire result set to filter by timestamp. This results in an in-memory fetch and filter operation, which is significantly slower than using a compound index.
- ✓
{ category: 1, timestamp: 1 }
Why this is correct
Following the ESR rule, this index allows MongoDB to perform an index seek on the equality field and then efficiently traverse the range of timestamps. This significantly reduces the number of index nodes visited and documents loaded into memory, resulting in optimal query performance and resource utilization.
- ✗
{ timestamp: 1 }
Why it's wrong here
A single-field index on timestamp does not help with the equality filter on category. The engine would be forced to perform a full collection scan or a large index scan, filtering the documents after retrieval, which is highly inefficient for queries filtering on specific categories.
About these practice questions
This C100DBA question is part of Courseiva's 222-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 C100DBA 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 C100DBA exam.