Time-series · Engineering

Timestamp handling in time-series collections

Accepted timestamp forms, bucket windows, time-zone semantics, retention, and what happens when time or series changes.

Time-series data is defined by time, so timestamp handling is part of the storage contract. NonoDB accepts several input forms, normalizes them to an instant, and uses that instant for bucket placement, range pruning, retention, and ordering.

The important distinction is between an instant and a local civil time. Stored values are instants; time zones are input or presentation concerns.

Accepted forms

The timeField accepts:

  • BSON dates in Extended JSON;
  • RFC 3339 strings;
  • epoch milliseconds.
{"ts": {"$date": "2026-01-01T00:00:00Z"}, "device": "sensor-1", "value": 21.5}

A missing or non-date time value is rejected. The collection does not guess a timestamp from insertion order.

Naive local times and date-only strings are rejected by the date parser because their instant is ambiguous. Store an explicit offset or Z.

Bucket placement

The bucket key is derived from the series (metaField) and a time window determined by granularity:

Granularity Window
seconds 1 hour
minutes 1 day
hours 30 days

Samples with the same series and the same window share a bucket. A range query can skip buckets outside the requested time range instead of decoding every row.

The exact bucket boundaries are an implementation detail, but the behavior is observable: range and retention queries operate on event time, not insertion time.

Time zones

Timezone identifiers such as Europe/Warsaw are not stored in the timestamp. The stored value is the UTC instant. Date expression operators can take an IANA zone to interpret local civil dates in a query, but the result is still an instant.

This is the same model as MongoDB’s BSON Date: the instant is universal, and the zone is a computation parameter. It also means a query for “2026-01-01 local time” must construct the correct instant explicitly.

Changing time or series

Changing timeField or metaField moves the row to another bucket. The old bucket is updated or rewritten, and the row is inserted into the new one. That is a real move, not a metadata flag.

This matters for updates. Updating a measurement value may rewrite a sealed bucket; moving a row can touch two buckets. The operation is still transactional, but it is not free.

Retention

expireAfterSeconds is relative to the event time, not the time of insertion. Expired rows are hidden immediately from reads; sealing drops them from the sealed payload.

Retention uses the same delete path as ordinary documents. Deleted values become bits in a per-bucket deletion bitmap, and the space is reclaimed on a later bucket rewrite or compaction. Deleting data does not shrink the LMDB file immediately.

Timestamps in queries

Time-range filters use the normal comparison operators:

{
"op": "find",
"coll": "readings",
"filter": {
"device": "sensor-1",
"ts": {
"$gte": {"$date": "2026-01-01T00:00:00Z"},
"$lt": {"$date": "2026-01-01T01:00:00Z"}
}
}
}

A secondary index on (device, ts) can narrow the scan, and the time-series planner also prunes buckets by the time range. explain reports whether an index was used.

Common mistakes

  • Storing timestamps as strings and querying them with date values. The types do not match.
  • Using a date-only string. It is rejected; store an explicit instant.
  • Assuming insertion time is event time. Retention and rollups use the event time.
  • Changing the time field and expecting the row to stay in the same bucket.
  • Forgetting that compaction is required to reclaim disk after retention.

Timestamps are not a formatting detail in a time-series database. They determine bucket placement, range pruning, retention, and query semantics. Treat them as the primary key of the time axis.

The time-series guide and dates guide document the accepted forms and operational details.

All engineering notes →Read the docs