mongodb - 执行时间毫秒等于 0 - MongoDB

标签 mongodb neo4j nosql

我使用了两个 NOSQL 数据库,MongoDBNeo4j 来处理相同的信息。我想比较使用第一个和第二个数据库的性能。我谈到了我的 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,如您所见:
enter image description here

那么,我该怎么做才能获得有关 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/

相关文章:

mongodb 在哈希字段上查询 $in

java - Neo4j - Java 堆空间。错误的查询或设置?

Neo4j:简单节点结构的递归查询

nosql - ElasticSearch 中的 GET 一致性(和 Quorum)

javascript - Mongoose :findOneAndUpdate ~500k 文档

mongodb - 在 MongoDB 查询优化器中选择完美索引的冲突

java - Neo4j 入门指南 (IntelliJ)

mongodb - 在 MongoDB 中,最大化每日日志文档写入性能的策略

database - 用于无向图的Nosql DB?

node.js - MongoDB 查询可以在 Mongo Shell 中工作,但不能在 Node.js 中工作?