2
我有一個集合搭配指數:MongoDB的解釋查詢計劃
{
"authorizations.participant.participantId" : 1,
"authorizations.action" : 1
}
我有一個查詢:
db.users.find({
"$query" : {
"$and" : [
{
"authorizations" : {
"$elemMatch" : {
"action" : "READ" ,
"participant.participantId" : {
"$in": ["5549b40444ae1e4a5764fb0a","5549b3f644ae1e4a5764facb"]
}
}
}
}
]
},
"$explain" : true
})
我想了解查詢執行計劃:
{
"cursor" : "BtreeCursor authorizations",
"isMultiKey" : true,
"n" : 22,
"nscannedObjects" : 22,
"nscanned" : 23,
"nscannedObjectsAllPlans" : 22,
"nscannedAllPlans" : 23,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 0,
"indexBounds" : {
"authorizations.participant.participantId" : [
[
"5549b3f644ae1e4a5764facb",
"5549b3f644ae1e4a5764facb"
],
[
"5549b40444ae1e4a5764fb0a",
"5549b40444ae1e4a5764fb0a"
]
],
"authorizations.action" : [
[
"READ",
"READ"
]
]
},
"allPlans" : [
{
"cursor" : "BtreeCursor authorizations",
"isMultiKey" : true,
"n" : 22,
"nscannedObjects" : 22,
"nscanned" : 23,
"scanAndOrder" : false,
"indexOnly" : false,
"nChunkSkips" : 0,
"indexBounds" : {
"authorizations.participant.participantId" : [
[
"5549b3f644ae1e4a5764facb",
"5549b3f644ae1e4a5764facb"
],
[
"5549b40444ae1e4a5764fb0a",
"5549b40444ae1e4a5764fb0a"
]
],
"authorizations.action" : [
[
"READ",
"READ"
]
]
}
}
],
"server" : "modi:27017",
"filterSet" : false,
"stats" : {
"type" : "KEEP_MUTATIONS",
"works" : 23,
"yields" : 0,
"unyields" : 0,
"invalidates" : 0,
"advanced" : 22,
"needTime" : 0,
"needFetch" : 0,
"isEOF" : 1,
"children" : [
{
"type" : "FETCH",
"works" : 23,
"yields" : 0,
"unyields" : 0,
"invalidates" : 0,
"advanced" : 22,
"needTime" : 0,
"needFetch" : 0,
"isEOF" : 1,
"alreadyHasObj" : 0,
"forcedFetches" : 0,
"matchTested" : 22,
"children" : [
{
"type" : "IXSCAN",
"works" : 23,
"yields" : 0,
"unyields" : 0,
"invalidates" : 0,
"advanced" : 22,
"needTime" : 0,
"needFetch" : 0,
"isEOF" : 1,
"keyPattern" : "{ authorizations.participant.participantId: 1, authorizations.action: 1 }",
"isMultiKey" : 1,
"boundsVerbose" : "field #0['authorizations.participant.participantId']: [\"5549b3f644ae1e4a5764facb\", \"5549b3f644ae1e4a5764facb\"], [\"5549b40444ae1e4a5764fb0a\", \"5549b40444ae1e4a5764fb0a\"], field #1['authorizations.action']: [\"READ\", \"READ\"]",
"yieldMovedCursor" : 0,
"dupsTested" : 22,
"dupsDropped" : 0,
"seenInvalidated" : 0,
"matchTested" : 0,
"keysExamined" : 23,
"children" : []
}
]
}
]
}
}
據我瞭解,雖然我可以"cursor" : "BtreeCursor authorizations"
,不是「nscannedObjects」= 22說有一個完整的收集掃描? (該集合中有22個文檔)。