Time Series Aggregation
Parent: MongoDB Aggregation Pipeline · Published reference · snapshot 2026-10-15
↓ Facts as markdownall context files
Depth-first rabbithole dossier for Time Series Aggregation; source-anchored research pack.
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
- [low] The map-reduce framework in MongoDB is a predecessor to the aggregation framework and is more complex to use. Sources: https://studio3t.com/knowledge-base/articles/mongodb-aggregation-framework/ [source]
Structure and components
- [low] If a time series collection contains `timeField` timestamps before 1970-01-01T00:00:00.000Z or after 2038-01-19T03:14:07.000Z, an index on the `timeField` must be created to optimize queries. Sources: https://www.mongodb.com/docs/manual/core/timeseries/timeseries-limitations.md [source]
How it works
- [low] Because the internal index for a time series collection lacks an index for the `_id` key, searching documents based on `_id` requires a COLLSCAN operation by default. Sources: https://blog.allegro.tech/2021/12/performance-evaluation-of-timeseries.html [source]
Measurements and reference values
- [low] The maximum size for documents within a time series collection is 4 MB. Sources: https://www.mongodb.com/docs/manual/core/timeseries/timeseries-limitations.md [source]
- [low] For any granularity configuration, the maximum size of a bucket in a time series collection is 1000 measurements or 125KB of data, whichever is lower. Sources: https://www.mongodb.com/docs/manual/core/timeseries/timeseries-limitations.md [source]
Problems, failure modes and limitations
- [low] The `$merge` aggregation stage cannot be used to add data from another collection to a time series collection, although it can be used to move data from a time series collection to another collection. Sources: https://www.mongodb.com/docs/manual/core/timeseries/timeseries-limitations.md [source]
- [low] MongoDB automatically enables block processing for eligible time series queries, and users cannot manually specify whether a query uses this feature. Sources: https://www.mongodb.com/docs/manual/core/timeseries/timeseries-querying.md [source]
- [low] The `query` field cannot be used for the `$geoNear` stage on a time series collection, but the `key` field must be specified. Sources: https://www.mongodb.com/docs/manual/core/timeseries/timeseries-limitations.md [source]
- [low] Documents in a time series collection are immutable once saved, meaning they cannot be updated or deleted. Sources: https://blog.allegro.tech/2021/12/performance-evaluation-of-timeseries.html [source]
- [low] Aggregation can leverage an index for `{deviceID: 1, timestamp: 1}` to avoid slow in-memory sort operations in the `$setWindowFields` stage. Sources: https://www.practical-mongodb-aggregations.com/examples/time-series/state-change-boundaries.html [source]
Comparisons and alternatives
- [low] In MongoDB, time series are materialized views that cover physical collections rather than actual collections. Sources: https://blog.allegro.tech/2021/12/performance-evaluation-of-timeseries.html [source]
- [low] Filling a time series collection was faster at 3:30,11 compared to 4:39,48 for a standard collection. (verified as of 2026-10-15) Sources: https://blog.allegro.tech/2021/12/performance-evaluation-of-timeseries.html [source]
Facts and statements
- [low] Starting in version 8.0, MongoDB may execute certain time series queries using block processing, which significantly improves performance and reduces overhead for long running aggregation pipelines that begin with $match, $sort (if used on the timeField), or $group; the improvement varies with workload and instance configuration. (verified as of 2026-10-15) Sources: https://www.mongodb.com/docs/manual/core/timeseries/timeseries-querying.md [source]
- [low] The `$out` aggregation stage is used to write documents to a time series collection. Sources: https://www.mongodb.com/docs/manual/core/timeseries/timeseries-limitations.md [source]
- [low] To group documents by distinct values in a time series collection, use the `$group` aggregation stage. Sources: https://www.mongodb.com/docs/manual/core/timeseries/timeseries-limitations.md [source]
- [low] Recent transactions in time series collections are kept in memory to facilitate real-time data streaming. Sources: https://www.mongodb.com/docs/manual/core/timeseries/timeseries-querying.md [source]
- [low] The minimum MongoDB version required is 5.0 due to the use of time series collections, the `$setWindowFields` stage, and the `$shift` operator. (verified as of 2026-10-15) Sources: https://www.practical-mongodb-aggregations.com/examples/time-series/state-change-boundaries.html [source]
- [low] A time series collection can be created using the command `db.createCollection("coll-ts", { timeseries: { timeField: "timestamp" } } )`. Sources: https://blog.allegro.tech/2021/12/performance-evaluation-of-timeseries.html [source]
- [low] Time series collections can be used to store sequences of device measurements over time for efficient storage and fast querying. Sources: https://www.practical-mongodb-aggregations.com/examples/time-series/state-change-boundaries.html [source]
- [low] The only way to delete data in a time series collection is to use the `drop()` command or define retention using the `expireAfterSeconds` parameter. Sources: https://blog.allegro.tech/2021/12/performance-evaluation-of-timeseries.html [source]
- [low] A time series collection for device status can be created with `db.createCollection("device_status", { "timeseries": { "timeField": "timestamp", "metaField": "deviceID", "granularity": "minutes" } });`. Sources: https://www.practical-mongodb-aggregations.com/examples/time-series/state-change-boundaries.html [source]
- [low] The internal index for a time series collection does not have a sorting feature and is not displayed. Sources: https://blog.allegro.tech/2021/12/performance-evaluation-of-timeseries.html [source]
Related concepts
- Time — is a part of Time Series Aggregation
- Series — is a part of Time Series Aggregation
- Aggregation — is a part of Time Series Aggregation
Children
- No children recorded.