C100DEV Indexing Practice Question
When should a TTL (Time-To-Live) index be used in a MongoDB collection?
⚠ Common exam trap
Candidates often select TTL indexes for precise, exact-time transactional data scheduling or permanent data archiving, confusing background automatic cleanup with deterministic job execution.
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
✓
To manage temporary or ephemeral data.
TTL indexes are designed to automatically remove documents from a collection after a certain period of time or at a specific time. This is ideal for ephemeral data like session logs, cached items, or temporary alerts. By relying on the database engine to handle the deletion, developers avoid writing custom cleanup scripts, ensuring that data is purged consistently without impacting application logic or manual overhead on the system.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
To keep data indefinitely.
Why it's wrong here
The TTL index is specifically built to expire and delete data. Using it to keep data indefinitely contradicts its core function. For persistent data, you should use standard indexes, as the TTL index will actively remove documents once the defined duration has passed, leading to unexpected data loss for long-term records.
- ✓
To manage temporary or ephemeral data.
Why this is correct
TTL indexes are perfect for data with a limited lifespan, such as user session data, audit logs, or temporary caches. The database automatically removes these documents once they reach their expiration time, reducing the need for manual cleanup and keeping the collection size manageable for the active data set.
- ✗
To speed up high-frequency write operations.
Why it's wrong here
TTL indexes do not improve write performance; in fact, they add overhead because the background process must periodically scan the collection to delete expired documents. This maintenance task consumes system resources, so they should be used exclusively for data expiration, not as a performance enhancement tool for general write operations.
- ✗
To ensure unique values in a field.
Why it's wrong here
TTL indexes do not enforce uniqueness. While you can create a unique index, a TTL index's primary and only role is to facilitate the automatic deletion of documents based on a date field. For uniqueness, you must use a standard unique index, which handles duplicate checks but does not delete documents.
About these practice questions
One of 259 original C100DEV 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 →
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.