我使用了两个 NOSQL 数据库,MongoDB 和 Neo4j 来处理相同的信息。我想比较使用第一个和第二个数据库的性能。我谈到了我的 MongoDB 问题 in this question : 执行时间 millis 始终等于 0。所以我在我的集合中添加了大约 250 个文档,但没有任何成功:
> db.team.find({common_name:"Milan"},{_id:0, "stadium.name":1}).explain("executionStats")
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "Progettino.team",
"indexFilterSet" : false,
"parsedQuery" : {
"common_name" : {
"$eq" : "Milan"
}
},
"winningPlan" : {
"stage" : "PROJECTION",
"transformBy" : {
"_id" : 0,
"stadium.name" : 1
},
"inputStage" : {
"stage" : "COLLSCAN",
"filter" : {
"common_name" : {
"$eq" : "Milan"
}
},
"direction" : "forward"
}
},
"rejectedPlans" : [ ]
},
"executionStats" : {
"executionSuccess" : true,
"nReturned" : 1,
"executionTimeMillis" : 0,
"totalKeysExamined" : 0,
"totalDocsExamined" : 253,
"executionStages" : {
"stage" : "PROJECTION",
"nReturned" : 1,
"executionTimeMillisEstimate" : 0,
"works" : 255,
"advanced" : 1,
"needTime" : 253,
"needFetch" : 0,
"saveState" : 0,
"restoreState" : 0,
"isEOF" : 1,
"invalidates" : 0,
"transformBy" : {
"_id" : 0,
"stadium.name" : 1
},
"inputStage" : {
"stage" : "COLLSCAN",
"filter" : {
"common_name" : {
"$eq" : "Milan"
}
},
"nReturned" : 1,
"executionTimeMillisEstimate" : 0,
"works" : 255,
"advanced" : 1,
"needTime" : 253,
"needFetch" : 0,
"saveState" : 0,
"restoreState" : 0,
"isEOF" : 1,
"invalidates" : 0,
"direction" : "forward",
"docsExamined" : 255
}
}
}
例如,在 MongoDB 中,此查询将比在 Neo4j 中工作得更好,因为我使用非规范化模型来表示有关球队体育场的信息。事实上,在 Neo4j 中,此查询需要 50 ms,如您所见:
那么,我该怎么做才能获得有关 MongoDB 中毫秒执行时间的信息?如果执行时间毫秒始终等于 0,我会遇到一些问题,因为我无法在使用两个不同的 NoSQL DB 的相同查询上显示不同的性能。
最佳答案
正如我在您回答的另一个问题中所述。你的收藏太少了。这是我从包含超过 3K 项的数据库中获得的输出。请注意我的 executionTimeInMillis 只有 2 毫秒。您将需要更多数据才能使 mongo 真正流失。说话 10K 以上的记录取决于您的机器的大小。
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "arenas.arenas",
"indexFilterSet" : false,
"parsedQuery" : {
"$and" : []
},
"winningPlan" : {
"stage" : "COLLSCAN",
"filter" : {
"$and" : []
},
"direction" : "forward"
},
"rejectedPlans" : []
},
"executionStats" : {
"executionSuccess" : true,
"nReturned" : 3718,
"executionTimeMillis" : 2,
"totalKeysExamined" : 0,
"totalDocsExamined" : 3718,
"executionStages" : {
"stage" : "COLLSCAN",
"filter" : {
"$and" : []
},
"nReturned" : 3718,
"executionTimeMillisEstimate" : 0,
"works" : 3724,
"advanced" : 3718,
"needTime" : 1,
"needFetch" : 4,
"saveState" : 31,
"restoreState" : 31,
"isEOF" : 1,
"invalidates" : 0,
"direction" : "forward",
"docsExamined" : 3718
},
"allPlansExecution" : []
}
关于mongodb - 执行时间毫秒等于 0 - MongoDB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31792492/