Time Series Collections

Since server 5.0 a time series collection replaces the hand-rolled bucket pattern of Bucket and Outlier. You declare a required timeField, an optional metaField for the labels identifying a series, and a granularity; the server packs measurements into hidden bucket documents, column by column.

Creating a time series collection and measuring what it savesPython
db.createCollection('readings', { expireAfterSeconds: 604800,
  timeseries: { timeField: 'ts', metaField: 'sensor', granularity: 'minutes' } });
const start = new Date('2026-09-20T00:00:00Z'), docs = [];
for (let i = 0; i < 4320; i++) for (const s of ['probe-a', 'probe-b'])
  docs.push({ ts: new Date(start.getTime() + i * 60000), sensor: { id: s, floor: 3 },
              tempC: 20 + Math.sin(i / 60) * 4 });
db.readings.insertMany(docs); db.readings_plain.insertMany(docs);   // the same 8,640
db.adminCommand({ fsync: 1 });
const p = db.readings_plain.stats(), t = db.readings.stats();
print('plain      dataSize ' + p.size + ' storage ' + p.storageSize);
print('timeseries dataSize ' + t.size + ' storage ' + t.storageSize + ' buckets ' +
      t.timeseries.bucketCount + ' index ' + db.readings.getIndexes()[0].name);
Output
plain      dataSize 768952 storage 212992
timeseries dataSize 74714 storage 49152 buckets 10 index sensor_1_ts_1

8,640 measurements land in 10 buckets: a tenth of the logical size, a quarter of the disk, and the gap widens with longer series because each column compresses on its own. sensor_1_ts_1 appears unasked — server 6.3 and later index metaField then timeField automatically. getCollectionNames() also lists system.buckets.readings and system.views: readings is a view that unpacks those buckets into one document per measurement. Queries stay ordinary, and $match on sensor.id with a ts range then $group with $dateTrunc returned hourly averages.

The restrictions show the shape through. updateOne fails with Cannot perform a non-multi update on a time-series collection, and an update may match only on metaField; an insert with no valid ts is rejected; transactions are not allowed, and metaField cannot be added later.

A time series collection packs one bucket per metadata value per time span
A time series collection packs one bucket per metadata value per time span