|
stephen.lee@10gen.com: minor nit, CanonicalQuery isn't used as a plan cache key; PlanCache key is. For example, {a:1} and {a:2} have non-equivalent representations in CanonicalQuery, but have an equivalent PlanCacheKey.
Would it fit your use case to have getPlansByQuery() include the PlanCacheKey for the query in its output? See below suggestion.
> db.foo.getPlanCache().getPlansByQuery({a:1})
|
[
|
{
|
"details" : {
|
// XXX insert {"planCacheKey": "eqa"} here?
|
"solution" : "(index-tagged expression tree: tree=Leaf { a: 1.0 }, pos: 0\n)"
|
},
|
"reason" : {
|
"score" : 2,
|
"stats" : {
|
"type" : "FETCH",
|
"works" : 1,
|
"yields" : 0,
|
"unyields" : 0,
|
"invalidates" : 0,
|
"advanced" : 0,
|
"needTime" : 0,
|
"needFetch" : 0,
|
"isEOF" : 1,
|
"alreadyHasObj" : 0,
|
"forcedFetches" : 0,
|
"matchTested" : 0,
|
"children" : [
|
{
|
"type" : "IXSCAN",
|
"works" : 1,
|
"yields" : 0,
|
"unyields" : 0,
|
"invalidates" : 0,
|
"advanced" : 0,
|
"needTime" : 0,
|
"needFetch" : 0,
|
"isEOF" : 1,
|
"keyPattern" : "{ a: 1.0 }",
|
"boundsVerbose" : "field #0['a']: [1.0, 1.0]",
|
"isMultiKey" : 0,
|
"yieldMovedCursor" : 0,
|
"dupsTested" : 0,
|
"dupsDropped" : 0,
|
"seenInvalidated" : 0,
|
"matchTested" : 0,
|
"keysExamined" : 0,
|
"children" : [ ]
|
}
|
]
|
}
|
},
|
"feedback" : {
|
"nfeedback" : 0,
|
"averageScore" : 0,
|
"stdDevScore" : 0,
|
"scores" : [ ]
|
},
|
"filterSet" : false
|
},
|
{
|
"details" : {
|
// XXX ditto here
|
"solution" : "(collection scan)"
|
},
|
"reason" : {
|
"score" : 2,
|
"stats" : {
|
"type" : "COLLSCAN",
|
"works" : 1,
|
"yields" : 0,
|
"unyields" : 0,
|
"invalidates" : 0,
|
"advanced" : 0,
|
"needTime" : 1,
|
"needFetch" : 0,
|
"isEOF" : 0,
|
"docsTested" : 0,
|
"children" : [ ]
|
}
|
},
|
"feedback" : {
|
|
},
|
"filterSet" : false
|
}
|
]
|
>
|
|