TTL Index on Timeseries Collection Extremely Slow

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Hi, 

      Details to include:

      Cluster Type: Sharded Cluster
      Number of Shards: 3
      MongoDB Version: 7.0
      TTL deletions on timeseries collections (system.buckets.<collection>) are extremely slow. The process uses a collection scan instead of an index scan.  The slowness becomes significant with high document counts. TTLMonitor log indicates deletion via collection scan for timeseries collections, not using index.

      {"t":{"$date":"2025-07-11T11:08:54.323+05:30"},"s":"I",  "c":"INDEX",    "id":5400702, "ctx":"TTLMonitor","msg":"Deleted expired documents using collection scan","attr":{"namespace":"<db>.system.buckets.<coll>","numDeleted":47935822,"durationMillis":7427156}}
      {"t":{"$date":"2025-07-11T09:05:07.167+05:30"},"s":"I",  "c":"INDEX",    "id":5400702, "ctx":"TTLMonitor","msg":"Deleted expired documents using collection scan","attr":{"namespace":"<db>.system.buckets.<coll>","numDeleted":7162,"durationMillis":772}}
      {"t":{"$date":"2025-07-11T11:08:54.323+05:30"},"s":"I",  "c":"INDEX",    "id":5400702, "ctx":"TTLMonitor","msg":"Deleted expired documents using collection scan","attr":{"namespace":"<db>.system.buckets.<coll>","numDeleted":47935822,"durationMillis":7427156}}
      {"t":{"$date":"2025-07-11T09:05:07.167+05:30"},"s":"I",  "c":"INDEX",    "id":5400702, "ctx":"TTLMonitor","msg":"Deleted expired documents using collection scan","attr":{"namespace":"<db>.system.buckets.<coll>","numDeleted":7162,"durationMillis":772}}
      {"t":{"$date":"2025-07-11T11:08:54.323+05:30"},"s":"I",  "c":"INDEX",    "id":5400702, "ctx":"TTLMonitor","msg":"Deleted expired documents using collection scan","attr":{"namespace":"<db>.system.buckets.<coll>","numDeleted":47935822,"durationMillis":7427156}} 

      Impact:

      Large deletion lag (up to months).

      Is there a workaround or setting to force index usage for TTL in timeseries?
      Are there any best practices or recommended approaches to speed up this process?

            Assignee:
            Unassigned
            Reporter:
            Ramkumar S
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: