Courseiva
CRUD Operations →hardMultiple Choice

C100DBA CRUD Operations Practice Question

A DBA is investigating a performance issue. A query on the `logs` collection uses the following filter: `{ $or: [ { level: "error" }, { level: "warning" } ] }`. There is an index on `{ level: 1 }`. Which statement correctly describes how MongoDB executes this query?

⚠ Common exam trap

The trap here is assuming that `$or` queries cannot use indexes or that only the first clause benefits from an index.

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

✓

MongoDB will use the index on `level` to perform two separate index scans and then merge the results.

For `$or` queries where each clause can be satisfied by an index, MongoDB performs separate index scans for each clause and then merges the results. This is more efficient than a collection scan. The index on `level` is suitable for both equality conditions, so the query will leverage it twice.

Answer analysis

Option-by-option breakdown

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

  • ✓

    MongoDB will use the index on `level` to perform two separate index scans and then merge the results.

    Why this is correct

    For `$or` queries, MongoDB can use an index for each clause if the clauses are supported by indexes. Here, both clauses are equality matches on `level`, which the index supports. MongoDB will execute two index scans and combine the results, often using a merge sort or deduplication step.

  • ✗

    MongoDB will use the index only if the `$or` clauses are combined with `$and`.

    Why it's wrong here

    `$or` clauses do not need to be combined with `$and` to use an index. Each clause of the `$or` can independently use an index. The presence of `$and` is irrelevant to index usage for the `$or` itself. This statement misrepresents how MongoDB optimizes `$or` queries.

  • ✗

    MongoDB will perform a collection scan because `$or` queries cannot use indexes.

    Why it's wrong here

    `$or` queries can use indexes. MongoDB will evaluate each clause of the `$or` independently and can use the same index for each clause if applicable. In this case, the index on `level` can be used for both `level: "error"` and `level: "warning"`, so a collection scan is not necessary.

  • ✗

    MongoDB will use the index on `level` but only for the first clause in the `$or` array.

    Why it's wrong here

    MongoDB evaluates all clauses in the `$or` array and can use indexes for each. It does not limit index usage to the first clause. The query planner will consider indexes for each branch and may use the same index for multiple branches if they share the same field.

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 →

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.