What are TTL Indexes?

Updated May 1, 2026

Short answer

TTL (Time To Live) indexes automatically remove documents from a collection after a certain amount of time.

Deep explanation

They are used on a Date field. A background thread runs every 60 seconds to delete expired documents.

Real-world example

Automatically deleting user session data or temporary OTPs.

Common mistakes

  • Setting TTL on a field that isn't a Date type (the index won't work).

Follow-up questions

  • Does TTL guarantee immediate deletion?

More MongoDB interview questions

View all →