-
Type: New Feature
-
Resolution: Unresolved
-
Priority: 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.