Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • MongoDB Query Optimization using explain

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 583
    Comment on it

    The MongoDB query optimizer processes chooses the most efficient query plan form the available indexes. Then mongoDB query system use this index to execute and return the result.

    You can use the db.collection.explain() or the cursor.explain() method into mongo shell to view statistics about the query plan for a given query.

    Below is the example for explain where first creating a cursor and then listing its value using explain()

    var cur = db.accounts.find()
    cur.explain()
    

    And this will return following output.

    {
      "cursor" : "BasicCursor",
      "isMultiKey" : false,
      "n" : 46,
      "nscannedObjects" : 46,
      "nscanned" : 46,
      "nscannedObjectsAllPlans" : 46,
      "nscannedAllPlans" : 46,
      "scanAndOrder" : false,
      "indexOnly" : false,
      "nYields" : 0,
      "nChunkSkips" : 0,
      "millis" : 0,
      "server" : "userName-pc:27017",
      "filterSet" : false
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: