MongoDB DEV · Question 202 · Single choice

Indexes and Performance: Question 1 What happens to a document in a TTL index when it expires? Choose the best answer:

Answer options

  1. A.
    It will be removed immediately
  2. B.
    It will remain in the collection until the next time it is read, at which point it will be automatically removed instead of returned
  3. C.
    It will no longer show up in queries, but will remain in the collection until eventually being removed by a background task that runs periodically
  4. D.
    It will remain in the collection until the next time it is read, at which point it will be present in the first cursor returned, but automatically removed afterwards
  5. E.
    It will be present in the cursors returned by queries until eventually being removed by a background task that runs periodically

Answer confidence: High

Correct answer: E

Explanation language: Chinese

TTL 索引由一个约每 60 秒运行一次的后台任务清理过期文档,在真正删除之前文档仍会被查询返回,所以 E 正确。A 立即删除、B/D 读到才删、C 查询看不到但还在,都误解了 TTL 的后台清理机制。

Papers containing this question

This question appears in 3 bank records. Public pages combine identical prompts and options. Selected questions display the highest-confidence record; the others show a short preview. Paper-based learning preserves each record's answer, explanation, and confidence.

AUTHOR · PROJECTS · OPEN SOURCE

Author & MongoDB projects

Building data platforms, MongoDB migration and sync tools, and cloud operations products.

Contact the author for any MongoDB needs.

Contact the author ↗mlhp123@outlook.com

Support the author

If this question bank helps you, optional donations are welcome.

Scan with Alipay to support the authorOpen full-size donation image ↗