Docs Menu

Docs HomeMongoDB Manual

Time Series Collection Limitations

On this page

This page describes limitations of time series collections.

The following features are not supported for time series collections.

You can't use aggregation pipeline stages $out and $merge to output or merge into to time series collections from another collection.

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 metaField field values.

  • The delete command may not limit the number of documents to be deleted. You must use a delete command with justOne: false or the deleteMany() method.

Update commands must meet the following requirements:

  • The query may only match on metaField field values.

  • The update command may only modify the metaField field 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: true or the updateMany() method.

  • 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.

Starting in MongoDB 6.0, you can add a secondary index to any field.

These index types aren't supported:

These index properties aren't supported:

The multikey index type is allowed on the metaField only.

These index properties are partially supported:

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. See setFeatureCompatibilityVersion

In MongoDB 5.0 and earlier:

  • Secondary indexes can only be defined on the metaField or the timeField.

  • If the metaField is a document, you can add secondary indexes on fields inside that document.

Tip

See also:

A time series collection can't be created as a capped collection.

A collection's type can only be set when creating the collection:

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 timeField and metaField parameters when creating the collection. After creation these parameters can't be modified.

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".

Starting in MongoDB 5.1 (and 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.

Starting in MongoDB 5.2 (and 5.1.2, 5.0.6), you can run sharding administration commands (such as moveChunk) on the system.buckets collection.

In versions earlier than MongoDB 5.0.6, you cannot run sharding administration commands for sharded time series collections.

When sharding time series collections, you can only specify the following fields in the shard key:

  • The metaField

  • Sub-fields of metaField

  • The timeField

You may specify combinations of these fields in the shard key. No other fields, including _id, are allowed in the shard key pattern.

When you specify the shard key:

Tip

Avoid specifying only the timeField as the shard key. Since the timeField increases monotonically, it may result in all writes appearing on a single chunk within the cluster. Ideally, data is evenly distributed across chunks.

To learn how to best choose a shard key, see:

You can't reshard sharded time series collections.

You can't write to time series collections in transactions.

Note

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 system.buckets).

←  Time Series CompressionTransactions →
Give Feedback
© 2022 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.