> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# Time Series Indexes

Indexes on time series collections generally behave like indexes on regular collections, but with several additional considerations and limitations.

If there are [secondary indexes](https://www.mongodb.com/docs/manual/reference/glossary.md#std-term-secondary-index) on [time series collections](https://www.mongodb.com/docs/manual/core/timeseries-collections.md#std-label-manual-timeseries-collection) and you need to downgrade the feature compatibility version (FCV), you must first drop any secondary indexes that are incompatible with the downgraded FCV. For more information, see [`setFeatureCompatibilityVersion`.](https://www.mongodb.com/docs/manual/reference/command/setfeaturecompatibilityversion.md#mongodb-dbcommand-dbcmd.setFeatureCompatibilityVersion)

Starting in version 6.0, you can add a secondary index to any field in a time series collection. MongoDB indexes time series collections by [buckets](https://www.mongodb.com/docs/manual/core/timeseries/timeseries-bucketing.md#std-label-timeseries-bucketing) of documents as opposed to individual documents. Time series buckets contain documents with shared metaField values, ordered by timeField values that are close together. MongoDB indexes the minimum and maximum values of all fields, except the metaField. Indexing buckets instead of individual documents reduces index size and improves query efficiency.

**Tip:**

To improve query performance, you can manually [add secondary indexes](https://www.mongodb.com/docs/manual/core/timeseries/timeseries-secondary-index.md#std-label-timeseries-add-secondary-index) to any field in your time series collection.

## Clustered Collection

By default, MongoDB clusters time series collections based on bucket time.

## Compound Indexes

**New in version 6.3**

Starting in MongoDB 6.3, MongoDB creates a default  [compound index](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-compound.md#std-label-index-type-compound) on both the metaField and timeField of a time series collection. MongoDB uses this index to improve query performance and speed.

You can add a [compound index](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-compound.md#std-label-index-type-compound) on the `timeField`, `metaField`, or measurement fields.

## Partial Indexes

**New in version 6.0**

Starting in MongoDB 6.0, you can use the [`$or`](https://www.mongodb.com/docs/manual/reference/operator/query/or.md#mongodb-query-op.-or), [`$in`](https://www.mongodb.com/docs/manual/reference/operator/query/in.md#mongodb-query-op.-in), and [`$geoWithin`](https://www.mongodb.com/docs/manual/reference/operator/query/geowithin.md#mongodb-query-op.-geoWithin) operators with [partial indexes](https://www.mongodb.com/docs/manual/core/index-partial.md#std-label-index-type-partial) on a time series collection.

You cannot create [partial indexes](https://www.mongodb.com/docs/manual/core/index-partial.md#std-label-index-type-partial) on the metaField and timeField.

## TTL Indexes

**New in version 7.0**

Starting in MongoDB 7.0, you can create a [TTL](https://www.mongodb.com/docs/manual/core/index-ttl.md#std-label-index-feature-ttl) index with a `partialFilterExpression` that relies only on the metaField. In versions prior to 6.3, you can only create TTL indexes based on the `expireAfterSeconds` parameter.

If your time series collection doesn't use the `expireAfterSeconds` option to expire documents, creating a partial TTL index sets an expiration time for matching documents only. If the collection uses `expireAfterSeconds` for all documents, you can use a partial TTL index to expire matching documents sooner.

## Prohibited Indexes

MongoDB does not allow the following index types on time series collections:

- [Text indexes](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text.md#std-label-index-type-text)

- [2d indexes](https://www.mongodb.com/docs/manual/core/indexes/index-types/geospatial/2d.md#std-label-2d-index)

- [Unique indexes](https://www.mongodb.com/docs/manual/core/index-unique.md#std-label-index-type-unique)

You cannot create sparse indexes on the metaField.

## Indexing Best Practices

- Use the metaField index for filtering and equality.

- Use the timeField and other indexed fields for range queries.

- General indexing strategies also apply to time series collections. For more information, see [Indexing Strategies.](https://www.mongodb.com/docs/manual/applications/indexes.md#std-label-indexing-strategies)

For more information and examples, see [Add Secondary Indexes to Time Series Collections.](https://www.mongodb.com/docs/manual/core/timeseries/timeseries-secondary-index.md#std-label-timeseries-add-secondary-index)
