0PricingLogin
MongoDB Academy · Lesson

Creating a Time Series Collection

Learners will create a time series collection, specifying the timeField, metaField, and granularity options.

Introduction to Time Series Collections

MongoDB 5.0 introduced native time series collections — a specialised collection type optimised for storing and querying measurements that change over time. Common use cases include IoT sensor readings, application metrics, financial ticks, and server monitoring data. Unlike regular collections, time series collections use a columnar storage format internally, dramatically reducing storage space and improving query performance on time-range filters.

Key Fields: timeField, metaField, granularity

Every time series collection requires three key options when created. The timeField is the document field that holds the timestamp (must be a BSON Date). The metaField identifies the series — for example, a sensor ID or device name. The granularity hint ('seconds', 'minutes', or 'hours') tells MongoDB how frequently measurements arrive, allowing it to optimise bucket sizing internally.

All lessons in this course

  1. Creating a Time Series Collection
  2. Inserting and Querying Time Series Data
  3. Windowed Aggregations on Time Series
  4. Automatic Data Expiration With expireAfterSeconds
← Back to MongoDB Academy