-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Optimization
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Right now the call to capture CBR query stats only inspects the CE of the root node to determine what method was used for the whole query. However, it is not always the case that all nodes in the tree have the same CE method so this is currently misleading. Here is an example (note that we are necessarily costing when there is just one plan here):
db.adminCommand({setParameter: 1, internalQueryCBRCEMode: "samplingCE"});
db.test.drop()
db.test.createIndex({a: 1})
db.test.insert([{a: 0}, {a: 1}])
db.test.find({$or: [{a: 0}, {a: 1}]}).limit(2).explain().queryPlanner.winningPlan
{
"isCached" : false,
"stage" : "LIMIT",
"costEstimate" : 0.004689209999999999,
"cardinalityEstimate" : 2,
"estimatesMetadata" : {
"ceSource" : "Metadata"
},
"limitAmount" : 2,
"inputStage" : {
"stage" : "FETCH",
"costEstimate" : 0.00447021,
"cardinalityEstimate" : 2,
"estimatesMetadata" : {
"ceSource" : "Sampling"
},
"nss" : "test.test",
"inputStage" : {
"stage" : "IXSCAN",
"costEstimate" : 0.00200581,
"cardinalityEstimate" : 2,
"numKeysEstimate" : 2,
"estimatesMetadata" : {
"ceSource" : "Sampling"
},
"nss" : "test.test",
"keyPattern" : {
"a" : 1
},
"indexName" : "a_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"a" : [ ]
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"a" : [
"[0.0, 0.0]",
"[1.0, 1.0]"
]
}
}
}
}