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

Hint a specific path of a wildcard index

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization

      Currently, users may hint the use of a wildcard index, but that does not avoid multi-planning because the wildcard index is presented as many different sub-indexes to the query planner. It would be helpful to allow hints for a specific field of a wildcard index.

      The example provided by alexander.ignatyev@mongodb.com, with a compound wildcard index, is:

      db.cwi.createIndex({"a.$**": 1, "b": 1});
      const docs = [{a: {x: 1, y : 2}, b: 1}, {a: {x: 2, y: 3}, b: 1}];
      db.cwi.insertMany(docs);
      const explain = db.cwi.find({"a.x": 1, b: 1}).explain("executionStats");
      explain.queryPlanner.winningPlan.inputStage.keyPattern;
      

      The above will print:

      { '$_path': 1, 'a.x': 1, b: 1 }
      

      But right now, this cannot be supplied as a hint.

            Assignee:
            alexander.ignatyev@mongodb.com Alexander Ignatyev
            Reporter:
            steve.tarzia@mongodb.com Steve Tarzia
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: