分析查询的性能 - mongoDB [英] Analyze performance of a query - mongoDB

查看:48
本文介绍了分析查询的性能 - mongoDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须分析 MongoDB 查询的性能.我读过我必须使用:

I have to analyze the performance of a MongoDB query. I read I must use:

cursor.explain("executionStats")

所以就我而言,我曾经分析过我的查询:

So in my case, I used to analyze my query:

> 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" : 87,
                "executionStages" : {
                        "stage" : "PROJECTION",
                        "nReturned" : 1,
                        "executionTimeMillisEstimate" : 0,
                        "works" : 89,
                        "advanced" : 1,
                        "needTime" : 87,
                        "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" : 89,
                                "advanced" : 1,
                                "needTime" : 87,
                                "needFetch" : 0,
                                "saveState" : 0,
                                "restoreState" : 0,
                                "isEOF" : 1,
                                "invalidates" : 0,
                                "direction" : "forward",
                                "docsExamined" : 87
                        }
                }
        }

我想知道执行查询需要多长时间.我不明白哪个是包含此信息的字段.

I want to know how long the query takes to be executed. I don't understand which is the the field containing this information.

推荐答案

您要查找的时间是 executionTimeInMillis 但是您的查询只遍历它看起来像 87 个文档,因此执行时间非常长小的.

The time your looking for is the executionTimeInMillis however your query is only going over it looks like 87 documents so the execution time is extremely small.

这篇关于分析查询的性能 - mongoDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆