Partial TTL indexes
Parent: MongoDB Compound Index Design: ESR, Selectivity, Covering and Multikey Bounds · Published reference · snapshot 2026-10-22 · skill ranked-40493c90
↓ Facts as markdownall context files
Source-anchored research for Partial TTL indexes. Run status: COMPLETED.
These notes link each claim to its source. Some citations identify archived research reports that are no longer hosted on this site. A published reference means the content is available; it does not certify independent review or accuracy.Read the editorial policy and follow the sources before relying on a claim.
Definitions
- For a time-series collection, the partial TTL index key is the collection timeField and the partialFilterExpression is restricted to the metaField or its subfields. MongoDB rejects an empty filter for this time-series TTL form. (high confidence) [source]
Structure and components
- A TTL index key must contain one field whose values are BSON Date values or arrays of Date values. A partial filter selects which documents the TTL index applies to; it does not make a compound TTL key valid, because compound indexes do not support TTL. (high confidence) [source]
How it works
- TTL expiration marks a document eligible for deletion; the background deletion process does not guarantee removal exactly at the expiration time and can lag under workload. Do not use partial TTL indexes as an exact deletion deadline. (high confidence) (verified as of 2026-10-18) [source]
- TTL indexes remain single-field indexes when partial: MongoDB ignores expireAfterSeconds on a compound index, so adding partialFilterExpression does not make a compound TTL index valid. (high confidence) [source]
- A time-series TTL index with an empty partialFilterExpression, such as {}, fails creation with InvalidOptions because the filter must target the metaField. (high confidence) (verified as of 2026-10-18) [source]
- By inference from partial-index semantics, a partial TTL index can reduce index storage and index-maintenance work when its filter selects a narrow cohort: MongoDB says partial indexes include only matching documents, and Percona's example describes the storage and write-maintenance benefit for partial indexes generally. (medium confidence) [source]
Problems, failure modes and limitations
- A partial filter excludes nonmatching documents from the TTL index, which can reduce index storage and write-maintenance costs. The TTL monitor still has to delete expired matching documents, so a smaller partial TTL index does not remove delete-workload risk. This combines the documented partial-index and TTL behaviors. (medium confidence) [source]
- If a time-series collection has no collection-level expireAfterSeconds, a partial TTL index sets expiration only for documents that match its filter. If collection-level TTL is configured, the partial TTL index can give matching documents shorter retention; it cannot extend retention because the collection-level TTL may delete them first. (high confidence) [source]
Comparisons and alternatives
- TTL deletion is asynchronous: MongoDB's TTL monitor checks every 60 seconds, and expired documents can remain longer under workload. Treat partial TTL as eventual cleanup rather than an exact deletion deadline. (medium confidence) (verified as of 2026-10-18) [source]
Facts and statements
- On an ordinary collection, MongoDB allows a single-field TTL index to use partialFilterExpression; only documents matching that filter are eligible for deletion by the index. The manual demonstrates this on a regular events collection, and a community answer reports the same behavior on MongoDB 4.2.8. (high confidence) [source]
- MongoDB source pages disagree about the first release with time-series partial TTL support: the current TTL and time-series manuals label the feature as new in 7.0, while the 7.0 compatibility notes and server time-series README say 6.3. These sources do not explain the difference, so the first supported release remains unresolved here. (high confidence) (verified as of 2026-10-18) [source]
- For a time-series collection, the TTL index key uses the collection timeField and its partial filter must constrain the metaField. If the collection also has expireAfterSeconds, a partial TTL index can shorten retention for matching measurements; if the index duration is longer, collection-level expiry removes the data first and the index has no effect. (high confidence) (verified as of 2026-10-18) [source]
- Percona's Percona Server for MongoDB 7.0.2-1 release highlights describe partial TTL indexes as a way to age time-series data more selectively; the release note does not establish the first MongoDB version that supports them. (low confidence) (verified as of 2023-10-05) [source]
Children
- No children recorded.