title: Analyze performance of a query - mongoDB
body: <p>I have to analyze the performance of a MongoDB query. I read I must use:</p>
  
  <pre><code>cursor.explain("executionStats")
  </code></pre>
  
  <p>So in my case, I used to analyze my query:</p>
  
  <pre><code>&gt; db.team.find({common_name:"Milan"},{_id:0, "stadium.name":1}).explain("executionStats")
  </code></pre>
  
  <p>And this is the result:</p>
  
  <pre><code>{
          "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
                          }
                  }
          }
  </code></pre>
  
  <p>I want to know how long the query takes to be executed. I don't understand which is the the field containing this information.</p>