Courseiva
Indexing and Performance →hardMultiple Choice

C100DBA Indexing and Performance Practice Question

Exhibit

db.collection.find({ 'tags': { $all: ['red', 'blue'] } })

Refer to the exhibit. Which index is most effective for this query?

⚠ Common exam trap

Exams often tempt candidates to create complex multi-key or compound index variants for array queries when a basic single-field index already natively supports the operation.

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

✓

{ tags: 1 }

The $all operator is used to find documents where the field contains all the specified elements. When indexing an array field, MongoDB creates a multikey index. A simple index on 'tags' is sufficient here because the multikey index structure inherently supports finding documents that contain specific array elements, enabling the query engine to efficiently narrow down the result set without scanning all documents in the collection.

Answer analysis

Option-by-option breakdown

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

  • ✓

    { tags: 1 }

    Why this is correct

    A multikey index on the 'tags' array allows MongoDB to map each individual element of the array to the document. This enables efficient lookup for specific values like 'red' and 'blue', making it the optimal choice for queries using the $all operator on an array field.

  • ✗

    { tags: 'hashed' }

    Why it's wrong here

    Hashed indexes are intended for equality lookups of single values and do not support range queries or array contents. Using a hashed index on an array field would not allow for the efficient retrieval of multiple elements, rendering the query inefficient and likely forcing a collection scan.

  • ✗

    { tags: 1, _id: 1 }

    Why it's wrong here

    While this compound index is valid, it adds unnecessary overhead to the index size by including the _id field. Since the query only filters on 'tags', a simple single-field multikey index is more space-efficient and provides the same query performance, avoiding unnecessary storage consumption.

  • ✗

    No index is required for array fields.

    Why it's wrong here

    Failing to index array fields will result in full collection scans, which are extremely performance-intensive as the dataset grows. To maintain high performance for queries involving array elements, an index is essential to avoid scanning every document in the collection to check the contents of the tags array.

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.