gpt4 book ai didi

mongodb - 了解 mongo db 解释

转载 作者:IT老高 更新时间:2023-10-28 11:08:21 25 4
gpt4 key购买 nike

我发起了一个查询并试图在 mongo 控制台上解释它并得到了

"isMultiKey" : true,
"n" : 8,
"nscannedObjects" : 17272,
"nscanned" : 17272,
"nscannedObjectsAllPlans" : 21836,
"nscannedAllPlans" : 21836,
"scanAndOrder" : true,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 184,

大部分内容在http://www.mongodb.org/display/DOCS/Explain 中都有解释。 ,但我不明白 nscannedObjectsAllPlans, nscannedAllPlans 是什么意思。有人可以帮忙吗?

谢谢

最佳答案

nscannednscannedObjects 报告获胜 query plan 的结果.

nscannedAllPlansnscannedObjectsAllPlans 报告所有计划的结果。

Doc

Number of index entries scanned. totalKeysExamined corresponds to the nscanned field returned by cursor.explain() in earlier versions of MongoDB.

例如:

t = db.jstests_explainb;
t.drop();

t.ensureIndex( { a:1, b:1 } );
t.ensureIndex( { b:1, a:1 } );

t.save( { a:0, b:1 } );
t.save( { a:1, b:0 } );

// Older mongodb (< 3.0? )
t.find( { a:{ $gte:0 }, b:{ $gte:0 } } ).explain( true );
{
"isMultiKey": false,
"n": 2,
"nscannedObjects": 2,
"nscanned": 2,
"nscannedObjectsAllPlans": 6,
"nscannedAllPlans": 6,
"scanAndOrder": false,
"indexOnly": false,
"nYields": 0,
"nChunkSkips": 0,
"millis": 2,
...
}

// MongoDB 4.4
t.find( { a:{ $gte:0 }, b:{ $gte:0 } } ).explain( true );
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "test.jstests_explainb",
...
"queryHash" : "CB67518C",
"planCacheKey" : "5E76CDD1",
"winningPlan" : {
"stage" : "FETCH",
"inputStage" : {
"stage" : "IXSCAN",
"keyPattern" : {
"a" : 1,
"b" : 1
},
"indexName" : "a_1_b_1",
}
},
"rejectedPlans" : [
{
"stage" : "FETCH",
"inputStage" : {
"stage" : "IXSCAN",
"keyPattern" : {
"b" : 1,
"a" : 1
},
"indexName" : "b_1_a_1",
}
}
],
...
},
"executionStats" : {
"executionSuccess" : true,
"nReturned" : 2,
"executionTimeMillis" : 0,
"totalKeysExamined" : 2, // <-- same as `nscanned`
"totalDocsExamined" : 2, // <--
"executionStages" : { ... }
"allPlansExecution" : [
{...},
{...}
]
}

关于mongodb - 了解 mongo db 解释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12510974/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com