在我看来,我在 MongoDB 查询计划中看到的唯一运算符是 COLLSCAN 或 IXSCAN。索引是b-tree,我猜MongoDB可以做索引搜索和索引扫描?如果是这样,我们怎么知道一个 seek id 执行了?
例如,在这个计划中(只是一个片段):
"executionStats" : {
"executionSuccess" : true,
"nReturned" : 17,
"executionTimeMillis" : 42,
"totalKeysExamined" : 25359,
"totalDocsExamined" : 1553,
"executionStages" : {
"stage" : "FETCH",
"filter" : {
"address.zipcode" : {
"$eq" : "10075"
}
},
"nReturned" : 17,
"executionTimeMillisEstimate" : 30,
"works" : 25360,
"advanced" : 17,
"needTime" : 25342,
"needYield" : 0,
"saveState" : 198,
"restoreState" : 198,
"isEOF" : 1,
"invalidates" : 0,
"docsExamined" : 1553,
"alreadyHasObj" : 0,
"inputStage" : {
"stage" : "IXSCAN",
"filter" : {
"cuisine" : {
"$regex" : ".*alian",
"$options" : "i"
}
},
"nReturned" : 1553,
"executionTimeMillisEstimate" : 30,
"works" : 25360,
"advanced" : 1553,
"needTime" : 23806,
"needYield" : 0,
"saveState" : 198,
"restoreState" : 198,
"isEOF" : 1,
"invalidates" : 0,
"keyPattern" : {
"cuisine" : 1.0
},
"indexName" : "cuisine_1",
"isMultiKey" : false,
"multiKeyPaths" : {
"cuisine" : []
},
"isUnique" : false,
"isSparse" : false,
"isPartial" : false,
"indexVersion" : 2,
"direction" : "forward",
"indexBounds" : {
"cuisine" : [
"[\"\", {})",
"[/.*alian/i, /.*alian/i]"
]
},
"keysExamined" : 25359,
"seeks" : 1,
"dupsTested" : 0,
"dupsDropped" : 0,
"seenInvalidated" : 0
}
我猜这是扫描(我故意进行了正则表达式搜索):
"totalKeysExamined" : 25359,
"totalDocsExamined" : 1553,
但我明白了
"seeks" : 1,
有没有关于如何解释计划的规则,为什么没有 IXSEEK 运算符?