Time Series Collection Limitations
On this page
- Unsupported Features
- Aggregation $out and $merge
- Updates and Deletes
- Time Series Secondary Indexes
- Time Series Secondary Indexes with MongoDB 6.0 and Later
- Time Series Secondary Indexes with MongoDB 5.0 and Earlier
- Capped Collections
- Modification of Collection Type
- Modification of
- Modification of
- Sharding Administration Commands
- Shard Key Fields
- View Limitations
This page describes limitations on using time series collections.
The following features are not supported for time series collections:
Atlas Device Sync is only supported if the time series collections are asymmetrically synchronized. For details, see Enable Atlas Device Sync.
Aggregation $out and $merge
You cannot use the
pipeline stages to add data from another collection to a time series
Updates and Deletes
Starting in MongoDB 5.1, you can perform some delete and update operations.
Delete commands must meet the following requirements:
You can only match on metaField field values.
Your delete command must not limit the number of documents to be deleted. Set
justOne: falseor use the
Update commands must meet the following requirements:
You can only match on the
You can only modify the
Your update document can only contain update operator expressions.
Your update command must not limit the number of documents to be updated. Set
multi: trueor use the
Your update command must not set upsert: true.
In MongoDB 5.0, time series collections only support insert operations and read queries. Updates and manual delete operations result in an error.
To automatically delete old data, set up automatic removal (TTL).
To remove all documents from a collection, use the
drop() method to drop the collection.
Time Series Secondary Indexes
There is improved support for secondary indexes in MongoDB 6.0.
Time Series Secondary Indexes with MongoDB 6.0 and Later
Starting in MongoDB 6.0, you can add a secondary index to any field.
These index types are not supported:
The TTL index property is not supported. For TTL deletion, use expireAfterSeconds.
You can only use the multikey index type on
These index properties are partially supported. You can create:
partial indexes on every field except
sparse indexes on the
For improvements to time series secondary indexes available starting in MongoDB 6.0, see Time Series Secondary Indexes in MongoDB 6.0.
If there are secondary indexes on time
series collections and you need to
downgrade the Feature Compatibility Version (FCV), you must first drop
any secondary indexes that are incompatible with the downgraded FCV.
Time Series Secondary Indexes with MongoDB 5.0 and Earlier
In MongoDB 5.0 and earlier:
metaFieldcan have secondary indexes.
timeFieldcan have secondary indexes.
metaFieldis a document, you can add secondary indexes on fields inside the document.
You cannot create a time series collection as a capped collection.
Modification of Collection Type
You can only set the collection type when you create a collection:
An existing collection cannot be converted into a time series collection.
A time series collection cannot be converted into a different collection type.
To move data from an existing collection to a time series collection, migrate data into a time series collection.
You can only set a collection's
parameters when you create the collection. You cannot modify these
After you set the
granularity, you can only increase it one level at
a time. The
granularity can change from
"minutes" or from
"hours". Other changes are
To change the
"minutes" and then to
Starting in MongoDB 5.1 (and 5.0.6), you can create sharded time series collections.
In versions earlier than MongoDB 5.0.6, you cannot shard time series collections.
Sharding Administration Commands
Starting in MongoDB 5.2 (and 5.1.2, 5.0.6), you can run sharding
administration commands (such as
moveChunk) on the
In versions earlier than MongoDB 5.0.6, you cannot run sharding administration commands for sharded time series collections.
Shard Key Fields
When sharding time series collections, you can only specify the following fields in the shard key:
You may specify combinations of these fields in the shard key. No other
_id, are allowed in the shard key pattern.
When you specify the shard key:
metaFieldcan be either a:
At the end of the shard key pattern
Avoid specifying only the
timeField as the shard key. Since
timeField increases monotonically, it may result in all writes appearing on a
single chunk within the cluster. Ideally, data is evenly distributed
To learn how to best choose a shard key, see:
You cannot reshard sharded time series collections.
You cannot write to time series collections in transactions.
Reads from time series collections are supported in transactions.
Time series collections are writable non-materialized views. Limitations for views apply to time series collections.
You cannot create a view from a time series bucket collection namespace (namely, a collection prefixed with