MongoDB 5.0 time series collections

A collection declared as time series is stored in a columnar bucketed format, which is a different physical layout for the same documents.

db.createCollection('metrics', {
  timeseries: {
    timeField: 'ts',
    metaField: 'tags',
    granularity: 'seconds',
  },
  expireAfterSeconds: 2592000,
})

// and what you give up:
//   no updates, no deletes of individual documents
//   the shard key cannot change
//   a normal collection cannot be converted in place

The storage reduction is large — often three to five times — because documents sharing a metadata value and a time bucket are stored together with the repeated fields factored out. The restrictions are the point: this is an append-only store for measurements, and anything needing to correct a past document wants a normal collection. Granularity is a hint about bucket size and choosing it badly costs both space and query speed, which makes it worth measuring rather than guessing.