Unsupported Features
The following features are not supported for time series collections.
Atlas Device Sync (Atlas Device Sync is supported if the time series collections are asymmetrically synchronized. For details, see Enable Atlas Device Sync.)
Constraints
The maximum size of a measurement document is 4 MB.
Aggregation $out and $merge
You can't use aggregation pipeline stages $out and $merge
to output or merge into to time series collections from another collection.
distinct Command
Due to the unique data structure of time series collections, MongoDB can't
efficiently index them for distinct values. Avoid using the
distinct command or db.collection.distinct() helper
method on time series collections. Instead, use a $group
aggregation to group documents by distinct values.
For example, to query for distinct meta.type values on documents
where meta.project = 10, instead of:
db.foo.distinct("meta.type", {"meta.project": 10})
Use:
db.foo.createIndex({"meta.project":1, "meta.type":1}) db.foo.aggregate([{$match: {"meta.project": 10}}, {$group: {_id: "$meta.type"}}])
This works as follows:
Creating a compound index on
meta.projectandmeta.typeand supports the aggregation.The
$matchstage filters for documents wheremeta.project = 10.The
$groupstage usesmeta.typeas the group key to output one document per unique value.
Document Size
The maximum size for documents within a time series collection is 4 MB.
Updates and Deletes
Starting in MongoDB 5.0.5, you can perform some delete and update operations.
Delete commands must meet the following requirements:
The query may only match on
metaFieldfield values.The delete command may not limit the number of documents to be deleted. You must use a delete command with
justOne: falseor thedeleteMany()method.
Update commands must meet the following requirements:
The query may only match on
metaFieldfield values.The update command may only modify the
metaFieldfield value.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 theupdateMany()method.The update command may not set upsert: true.
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.
If a time series collection contains documents with timeField
timestamps before 1970-01-01T00:00:00.000Z or after
2038-01-19T03:14:07.000Z, no documents are deleted from the
collection by the TTL "time to live" feature.
For details on TTL deletes, see Expire Data from Collections by Setting TTL.
Secondary Indexes
You can add secondary indexes on the fields
specified as the timeField and the metaField. If the field value
for the metaField field is a document, you can also create secondary
indexes on fields inside that document.
The metaField doesn't support the following index types:
Secondary indexes don't support the following index properties:
Capped Collections
A time series collection can't be created as a capped collection.
Modification of Collection Type
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.
Modification of timeField and metaField
You can only set a collection's timeField and metaField
parameters when creating the collection. After creation these parameters
can't be modified.
Modification of granularity
Once the granularity is set it can only be increased by one level at
a time. From "seconds" to "minutes" or from "minutes" to
"hours". Other changes are not allowed. If you need to change the
granularity from "seconds" to "hours", first increase the
granularity to "minutes" and then to "hours".
Sharding
Starting in MongoDB 5.0.6, sharded time series collections are
supported. When using sharded time series collections, you cannot modify
the granularity of a sharded time series collection.
In versions earlier than MongoDB 5.0.6, you cannot shard time series collections.
Sharding Administration Commands
You cannot run sharding administration commands on sharded time series collections.
Transactions
You can't write to time series collections in transactions.
Note
Reads from time series collections are supported in transactions.
Snapshot Isolation
Read operations on time series collections with read concern
"snapshot" guarantee snapshot isolation only in the absence of
concurrent drop or rename operations on collections in the read
operation. Re-creating a time series collection on the same namespace
with different granularity setting does not yield full snapshot
isolation.