- Introduction to MongoDB >
- Databases and Collections >
- Time Series Collections
Time Series Collections¶
On this page
New in version 5.0.
Time series collections efficiently store sequences of measurements over a period of time. Time series data is any data that is collected over time and is uniquely identified by one or more rarely-changing parameters. The unchanging parameters that identify your time series data is generally your data source’s metadata.
Example | Measurement | Metadata |
---|---|---|
Weather data | Temperature | Sensor identifier, location |
Stock data | Stock price | Stock ticker, exchange |
Website visitors | View count | URL |
Benefits¶
Compared to normal collections, storing time series data in time series collections improves query efficiency and reduces the disk usage for time series data and secondary indexes.
When you insert data, time series collections use an optimized columnar storage format. Compared to normal collections, this storage format provides the following benefits:
- Improved query efficiency
- Increased WiredTiger cache usage
- Decreased input and output
- Reduced disk usage for both data and secondary indexes
Behavior¶
Time series collections behave like normal collections. You can insert and query your data as you normally would. MongoDB treats time series collections as writable non-materialized views on internal collections that automatically organize time series data into an optimized storage format on insert.
When you query time series collections, you operate on one document per measurement. Queries on time series collections take advantage of the optimized internal storage format and return results faster.
Important
Backward-Incompatible Feature
You must drop time series collections before downgrading:
- MongoDB 6.0 or later to MongoDB 5.0.7 or earlier.
- MongoDB 5.3 to MongoDB 5.0.5 or earlier.
Internal Index¶
The implementation of time series collections uses internal collections
that reduce disk usage and improve query efficiency. Time series
collections automatically order and index data by time. The internal
index for a time series collection is not displayed by
listIndexes
.
Tip
To improve query performance, you can manually add secondary indexes on measurement fields or any field in your time series collection.
Get Started¶
To get started with time series collections, see Create and Query a Time Series Collection.
- Create and Query a Time Series Collection
- Set up Automatic Removal for Time Series Collections (TTL)
- Set Granularity for Time Series Data
- Add Secondary Indexes to Time Series Collections
- Migrate Data into a Time Series Collection
- Build Materialized Views on Top of Time Series Data
- Shard a Time Series Collection
- Best Practices for Time Series Collections
- Reference