Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-95352

Investigate why some time series queries cannot be answered using only indexes with Query Settings

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Integration
    • ALL
    • Hide

      In the ticket below, I've attached a minimal standalone test to reproduce the issue

      Show
      In the ticket below, I've attached a minimal standalone test to reproduce the issue
    • QI 2024-11-11, QI 2024-11-25, QI 2024-12-09

      When testing the Query Settings mechanism on time series collections, I have noticed that some queries cannot be fully answered by indexes, while the same query on a normal collection can. One example is the following $lookup command, where both collections are time series collections:

      pipeline: [
            { $match: { a: 1, b: 5 } },
            {
              $lookup:
                { 
                  from: secondaryColl.getName(),
                  localField: "a",
                  foreignField: "a",
                  as: "output"
                }
            }
      ]; 

      The $lookup stage results into sub-query, with the following Canonical Query:

      [j0:prim] ns=test.system.buckets.secondaryTree: $or
      [j0:prim]     $and
      [j0:prim]         control.max.a $_internalExprGte 1.0
      [j0:prim]         control.min.a $_internalExprLte 1.0
      [j0:prim]     $expr {$ne: [{$type: ["$control.min.a"]}, {$type: ["$control.max.a"]}]}
      [j0:prim] Sort: {}
      [j0:prim] Proj: {}
      [j0:prim] Collation: { locale: "simple" }

      given the following query settings:

      { indexHints: [ { ns: { db: "test", coll: "secondary" }, allowedIndexes: [ { a: 1.0 } ] } ] } 

      The interesting part is the the first branch of the $or condition can be fully answered using indexes, but the second can't, which seems to be added only for time series collections: $expr {$ne: [{$type: ["$control.min.a"]}, {$type: ["$control.max.a"]}]}

      As this issue was blocking my ticket SERVER-86996, I've left some comments which should be fixed by this ticket.

      These issue occur when running the `jstests/core/query/query_settings/query_settings_index_application_aggregate.js` test with the `timeseries_crud_jscore_passthrough` suite.

       

            Assignee:
            maddie.zechar@mongodb.com Maddie Zechar
            Reporter:
            victorfilip.ghita@mongodb.com Victor Ghita
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: