C100DEV CRUD Operations Practice Question
A reporting service reads from the 'sensors' collection, which holds millions of documents each containing an 'active' boolean field. The service queries only for documents where 'active' is true and reads a handful of fields. A developer wants the query to avoid scanning documents that are inactive. Which index should be created to support this access pattern most directly?
⚠ Common exam trap
The trap here is believing a sparse index reduces work when the field is present in every document, when sparse only excludes documents that omit the field.
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
✓
db.sensors.createIndex({ active: 1 })
An equality filter on a single boolean field is best served by a single-field index on that field, which allows the planner to seek directly to the matching entries and fetch only relevant documents. A compound index led by _id, a text index, or a sparse variant cannot provide that access path, because the query does not supply a usable prefix or field type for those structures.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
db.sensors.createIndex({ active: 1 }, { sparse: true })
Why it's wrong here
A sparse index omits documents that lack the indexed field entirely. Since every sensor document contains an 'active' boolean, the sparse option excludes nothing and provides no advantage over a normal index here. It still indexes true and false values, so it does not reduce the index size or change the access path for this scenario.
- ✗
db.sensors.createIndex({ _id: 1, active: 1 })
Why it's wrong here
A compound index whose leading field is _id cannot be used efficiently to filter on 'active' alone. The query planner can only use an index prefix, so with _id first and no _id predicate in the query, the 'active' portion is not usable as an access path. The query would still scan or fall back to a full collection scan.
- ✓
db.sensors.createIndex({ active: 1 })
Why this is correct
A single-field ascending index on 'active' lets the query planner satisfy the equality predicate on that field by scanning only the matching index entries and fetching the corresponding documents. Because the filter is a simple equality on one field, this index directly narrows the candidate set and avoids a full collection scan for the inactive documents.
- ✗
db.sensors.createIndex({ active: "text" })
Why it's wrong here
A text index is designed for full-text search over string content and tokenizes fields for word matching. It cannot serve an equality filter on a boolean field, and a boolean value is not valid text-index content in the way this query requires. The planner would not use this index for the active = true predicate.
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 →
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.