<!-- llms-explorer concept facts · https://llms-explorer.com/tree/bucket-level-predicate-rewriting-for-measurement-operators/ · pack 2026-10-22 · ~1094 tokens -->

# Bucket-level predicate rewriting for measurement operators

> Source-anchored research for Bucket-level predicate rewriting for measurement operators. Run status: COMPLETED.

Parent: [MongoDB Time-Series Query and Index Optimization](https://llms-explorer.com/tree/mongodb-time-series-query-and-index-optimization/) · 5 facets · 8 facts · page: https://llms-explorer.com/tree/bucket-level-predicate-rewriting-for-measurement-operators/

## Structure and components

- MongoDB's 2026 SERVER-126494 report reproduces an incorrect result when a measurement field contains NaN and an aggregation applies $match {v: {$lt: 50}} followed by an inclusion $project: the regular collection returns {v: 1}, but the time-series collection returns no row. Jira lists 9.1.0-rc0 as the fix version. (low confidence) (verified as of 2026-09-29) — [source](https://jira.mongodb.org/browse/SERVER-126494)

## How it works

- MongoDB Jira recorded historical false negatives when buckets mixed array and scalar values or mixed objects and non-objects on measurement paths; SERVER-59505 is marked fixed in 5.0.4, 5.1.0-rc3, and 5.2.0. SERVER-60565 describes splitting buckets when an incoming measurement has an incompatible schema. (high confidence) — [source](https://jira.mongodb.org/browse/SERVER-59505)

## Problems, failure modes and limitations

- The generator declines object, array, and null operands; non-default-collation string comparisons; computed or removed fields; and non-time internal LT/LTE comparisons without type bracketing. When mixed schema cannot be ruled out, it adds a type-equality fallback across control.min/control.max path prefixes. SERVER-59505 records earlier false negatives when array/scalar or object/scalar values shared a bucket. (high confidence) (verified as of 2026-10-22) — [source](https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/db/query/timeseries/bucket_level_comparison_predicate_generator.cpp)

## Comparisons and alternatives

- For non-time measurement fields, MongoDB treats the min/max predicate as a candidate filter rather than proof that every measurement matches. The generator disables a tight predicate because missing measurement values are omitted from control summaries and array-valued controls can change comparison semantics; MongoDB's query notes say individual measurements are still filtered after bucket selection. (high confidence) (verified as of 2026-10-22) — [source](https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/db/query/timeseries/bucket_level_comparison_predicate_generator.cpp)

## Facts and statements

- Starting in MongoDB 6.0, a $match on a non-time measurement field can add a bucket filter to the COLLSCAN or FETCH: equality uses control.min <= value and control.max >= value; $gt/$gte compare against control.max; and $lt/$lte compare against control.min. (high confidence) (verified as of 2026-10-22) — [source](https://github.com/mongodb/mongo/blob/master/src/mongo/db/query/timeseries/README.md)
- For the special timeField path, the generator only uses the bucket comparison rewrite for BSON Date operands. A Stack Overflow explain example showed Date bounds generating control.min/control.max and _id constraints with IXSCAN, while numeric timestamp literals left an eventFilter and COLLSCAN; the answer attributes this to type-sensitive query semantics. (medium confidence) (verified as of 2025-12-24) — [source](https://raw.githubusercontent.com/mongodb/mongo/master/src/mongo/db/query/timeseries/bucket_level_comparison_predicate_generator.cpp)
- Independent writeups support the general summary-filtering design but differ in scope: OneUptime describes measurement-threshold indexes using control.min/control.max, while Percona's MongoDB 5.0 example shows the same summary-field filters for timestamp comparisons only. The Percona example is context for bucket pruning, not a test of measurement-field predicates. (medium confidence) — [source](https://oneuptime.com/blog/post/2026-03-31-mongodb-time-series-secondary-indexes/markdown)
- MongoDB's manual describes grouping by matching metaField values and nearby timeField values as a way to narrow queries to a range of buckets; measurement comparisons add a separate control-field filter in the query rewrite. (high confidence) — [source](https://www.mongodb.com/docs/manual/core/timeseries/timeseries-querying/)
