Docs Menu
Docs Home
/
MongoDB Manual
/ /

Time Series Collection Limitations

On this page

  • Unsupported Features
  • Aggregation $out and $merge
  • Updates and Deletes
  • Time Series Secondary Indexes
  • Time Series Secondary Indexes
  • Time Series Secondary Indexes with MongoDB 5.0 and Earlier
  • Capped Collections
  • Modification of Collection Type
  • Modification of timeField and metaField
  • Modifying Bucket Parameters
  • Sharding
  • Sharding Administration Commands
  • Shard Key Fields
  • Resharding
  • Transactions
  • Views

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.

You cannot use the $out or $merge aggregation pipeline stages to add data from another collection to a time series collection.

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: false or use the deleteMany() method.

Update commands must meet the following requirements:

  • You can only match on the metaField field value.

  • You can only modify the metaField field value.

  • Your update document can only contain update operator expressions.

  • Your update command must not limit the number of documents to be updated. Set multi: true or use the updateMany() method.

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

MongoDB 6.0 and later features improved support for secondary indexes on time series collections. For a summary of these options, see Time Series Secondary Indexes in MongoDB 6.0 and Later.

Starting in MongoDB 6.3, time series collections support the expireAfterSeconds index property for partial indexes on the metaField. For earlier versions of MongoDB, use the collection level expireAfterSeconds parameter.

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

These index types are partially supported:

These index types aren't supported:

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:

  • The metaField can have secondary indexes.

  • The timeField can have secondary indexes.

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

Tip

See also:

You cannot create a time series collection as a capped collection.

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 timeField and metaField parameters when you create the collection. You cannot modify these parameters later.

Once you set a collection's granularity or custom bucketing parameters bucketMaxSpanSeconds and bucketRoundingSeconds, you can increase them, but not decrease them. Use the collMod command to modify the parameters. For example:

db.runCommand({
collMod: "timeseries",
timeseries: { bucketMaxSpanSeconds: 3600, bucketRoundingSeconds: 3600 }
})

Note

bucketMaxSpanSeconds and bucketRoundingSeconds must be equal. If you modify one parameter, you must also set the other to the same value.

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.

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 cannot reshard sharded time series collections.

You cannot 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).

Back

Time Series Compression