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)