On this page
The following features are not supported for time series collections.
The maximum size of a measurement document is 4 MB.
Starting in MongoDB 5.1, you can perform some delete and update operations.
Delete commands must meet the following requirements:
- The query may only match on
- The delete command may not limit the number of documents to be
deleted. You must use a delete command with
justOne: falseor the
Update commands must meet the following requirements:
- The query may only match on
- The update command may only modify the
- The update must be performed with an update document that contains only update operator expressions.
- The update command may not limit the number of documents to be
updated. You must use an update command with
multi: trueor the
- The update command may 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.
You can add secondary indexes on the fields
specified as the
timeField and the
metaField. If the field value
metaField field is a document, you can also create secondary
indexes on fields inside that document.
In MongoDB 5.1, the
metaField doesn't support text indexes.
In MongoDB 5.0, the
metaField doesn't support the following index
Secondary indexes don't support the following index properties:
A time series collection can't be created as a capped collection.
A collection's type can only be set when creating the collection:
- An existing collection can't be converted into a time series collection.
- A time series collection can't 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 creating the collection. After creation these parameters
can't be modified.
granularity is set it can only be increased by one level at
a time. From
"minutes" or from
"hours". Other changes are not allowed. If you need to change the
"hours", first increase the
"minutes" and then to
Starting in MongoDB 5.1 (and 5.0.6), sharded time series collections are
supported. When using sharded time series collections, you cannot modify
granularity of a sharded time series collection.
In versions earlier than MongoDB 5.0.6, you cannot shard time series collections.
In versions earlier than MongoDB 5.0.6, you cannot run sharding administration commands for sharded time series collections.
MongoDB does not support creating zones for sharded time series collections.
When sharding time series collections, you can only specify the following fields in the shard key:
- Sub-fields of
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:
- A ranged shard key
- 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:
Reads from time series collections are supported in transactions.