Courseiva
Indexing →hardMultiple Choice

C100DEV Indexing Practice Question

A developer is working with a collection that has a compound index on { a: 1, b: 1, c: 1 }. They run a query that includes a filter on `a` and a sort on `c`. The query is: `db.collection.find({ a: 5 }).sort({ c: 1 })`. Which of the following best describes how MongoDB will execute this query?

⚠ Common exam trap

The trap here is assuming that any field in a compound index can be used for sorting if the equality field is first, but the sort field must be contiguous after the equality fields.

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

✓

The query will use the index to filter on `a` and then sort the results in memory by `c`.

With a compound index { a: 1, b: 1, c: 1 }, an equality filter on `a` can use the index efficiently. However, a sort on `c` cannot be satisfied by the index because `b` intervenes. MongoDB must perform an in-memory sort on the filtered results. The index is still used for filtering, but it does not avoid the sort stage.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    The query will use the index to both filter on `a` and sort by `c`, avoiding an in-memory sort.

    Why it's wrong here

    For the index to support sorting by `c`, the sort field must be contiguous after the equality field in the index. Since `b` is between `a` and `c`, the index cannot provide sorted results for `c` when filtering on `a`. MongoDB will have to sort in memory. Therefore, this statement is false.

  • ✓

    The query will use the index to filter on `a` and then sort the results in memory by `c`.

    Why this is correct

    The index { a: 1, b: 1, c: 1 } can be used to efficiently filter on `a` because `a` is the leading field. However, the sort on `c` cannot be satisfied by the index alone because `b` is between `a` and `c` in the index. MongoDB will need to perform an in-memory sort on `c` after retrieving the documents. This is the correct behavior.

  • ✗

    The query will use a covered index scan because all fields are in the index.

    Why it's wrong here

    A covered index scan requires that all fields in the query filter and projection are in the index. Here, the query only filters on `a` and sorts on `c`, but the projection is not specified, so it likely returns all fields. Even if it only returned a and c, the index contains a, b, and c, so it could be covered if the projection includes only a and c. However, the sort on c cannot be satisfied by the index order, so it's not a covered index scan for the sort. The query will still need to fetch documents or sort in memory.

  • ✗

    The query will not use the index at all and will perform a collection scan.

    Why it's wrong here

    The index can still be used to filter on `a` because `a` is the first field in the index. MongoDB will use the index to quickly find documents where a: 5, then sort those results in memory by `c`. A collection scan would be less efficient, so this statement is incorrect.

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 →

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 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.