$bucket on untracked viewless timeseries can optimize the pipeline on mongos before prepending $_internalUnpackBucket

XMLWordPrintableJSON

    • Query Integration
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      For timeseries collections, timeseries rewrites (prepending $_internalUnpackBucket) must happen before any optimizations. On mongos we optimize the pipeline if one of the following are true: 

      • routingTableIsAvailable
      • requiresCollationForParsingUnshardedAggregate
      • hasChangeStream
      • shouldDoFLERewrite

      If routingTableIsAvailable is true, then we can perform the timeseries rewrite on mongos and should optimize the pipeline correctly. 

      If routingTableIsAvailable is false then we do not perform the timeseries rewrite and should not optimize the pipeline. shouldDoFLERewrite and hasChangeStream should be always false for timeseries collections. Therefore, the only time routingTableIsAvailable is false and we might optimize the pipeline is if requiresCollationForParsingUnshardedAggregate is true. requiresCollationForParsingUnshardedAggregate is true for $bucket and $merge. $merge cannot run on timeseries collections.

      This ticket should investigate if there is a correctness issue and to avoid optimizing the pipeline if requiresCollationForParsingUnshardedAggregate is true and routingTableIsAvailable is false and the collection is a viewless timeseries. This scenario can only happen for untracked viewless timeseries collections running $bucket pipelines.

            Assignee:
            Unassigned
            Reporter:
            Gil Alon
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: