Courseiva
Indexing and Performance →hardMultiple Choice

C100DBA Indexing and Performance Practice Question

Exhibit

db.collection.createIndex({ 'tags': 1 })
db.collection.createIndex({ 'location': '2dsphere' })

Refer to the exhibit. A developer attempts to run a query using both 'tags' and 'location' in a single $and operation. What is the expected behavior regarding index usage?

⚠ Common exam trap

Candidates often assume that MongoDB will always use an index intersection for any query with multiple conditions, ignoring the fact that the optimizer prioritizes single compound indexes over intersection plans.

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 optimizer may choose an index intersection plan.

MongoDB can utilize multiple indexes for a single query through an 'index intersection' execution plan. However, the query optimizer decides whether to perform an intersection or use just one index based on cost. For complex queries involving geo-spatial data and arrays, intersection might be less efficient than a single compound index, and the optimizer may choose a collection scan if intersection costs are deemed too high.

Answer analysis

Option-by-option breakdown

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

  • ✗

    It will always use both indexes simultaneously.

    Why it's wrong here

    While index intersection is supported, it is not guaranteed. The MongoDB query optimizer evaluates the cost of intersection versus scanning a single index or collection. It will only perform an intersection if the estimated cost is lower than other available plans, which is not guaranteed for every query.

  • ✗

    It will fail because compound indexes are required.

    Why it's wrong here

    MongoDB does not strictly require a compound index for queries involving multiple fields. It is perfectly legal to have separate indexes on distinct fields. The query will execute successfully, either by using one of the indexes or potentially by performing an index intersection if the optimizer deems it optimal.

  • ✓

    The optimizer may choose an index intersection plan.

    Why this is correct

    MongoDB's query optimizer can use index intersection to combine multiple single-field indexes to satisfy a query. It will evaluate the candidate indexes and, if the cost analysis indicates that intersection is the most efficient path, it will create a plan using both indexes for the filter.

  • ✗

    It will ignore all indexes and scan the collection.

    Why it's wrong here

    The query will not automatically default to a collection scan unless the optimizer determines that using the available indexes is more expensive than reading the entire collection. Since indexes exist, they will be evaluated as potential candidates for the query execution plan, provided they match the filtering criteria.

About these practice questions

One of 222 original C100DBA practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.