Courseiva
Indexing and Performance →mediumMultiple Choice

C100DBA Indexing and Performance Practice Question

An application frequently queries a large collection by 'user_id' and 'status', sorting the results by 'timestamp'. Which index provides the most efficient execution plan?

⚠ Common exam trap

Candidates frequently ignore the ESR rule, creating indexes that include fields in the wrong order, which prevents the query engine from efficiently using the index for both filtering and sorting.

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

✓

{ user_id: 1, status: 1, timestamp: 1 }

To optimize this query, the ESR (Equality, Sort, Range) rule must be applied. The 'user_id' and 'status' fields are equality filters, while 'timestamp' is used for sorting. An index of {user_id: 1, status: 1, timestamp: 1} allows MongoDB to satisfy the query filters and provide the sort order directly from the index, avoiding a blocking sort operation in memory which is critical for performance on large collections.

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, user_id: 1, status: 1 }

    Why it's wrong here

    This index places the sort field first, which prevents the index from being used effectively for equality filtering. The query engine would likely perform a collection scan or a suboptimal index scan, requiring an in-memory sort phase that consumes significant memory and limits scalability for large result sets.

  • ✗

    { user_id: 1, timestamp: 1, status: 1 }

    Why it's wrong here

    Placing the sort field between two equality fields prevents the index from supporting a covered sort. The query engine will be unable to use the index to order the results, forcing a slow, blocking sort operation that could easily exceed the 32MB limit for memory-based sorting in MongoDB.

  • ✓

    { user_id: 1, status: 1, timestamp: 1 }

    Why this is correct

    This structure follows the ESR rule perfectly. The equality fields appear first, narrowing down the search space, followed by the field required for sorting. This combination allows the query engine to retrieve documents in the desired order without performing an additional, resource-intensive sort operation after fetching the data.

  • ✗

    { user_id: 1, status: 1 }

    Why it's wrong here

    While this index optimizes the filtering, it does not support the sort order. MongoDB will still need to perform an in-memory sort after retrieving the documents, leading to decreased performance. Including the sort field in the index is essential to eliminate the blocking sort and improve overall response latency.

About these practice questions

Courseiva writes every C100DBA question from scratch — 222 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 →

How Courseiva writes practice questions · Editorial policy

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.