Introducing other analytics methods
MongoDB provides the explain()
function, which provides you a detailed procedure for the current operator. For instance, consider following command:
db.testcollection.find().sort({x: -1}).explain()
The preceding command will execute the find
operator and sort the records descending from the x
field. Then, the explain()
function shows an output as follows:
{ "cursor": "BasicCursor", "isMultiKey": false, "n": 100000, "nscannedObjects": 100000, "nscanned": 100000, "nscannedObjectsAllPlans": 100000, "nscannedAllPlans": 100000, "scanAndOrder": true, "indexOnly": false, "nYields": 1563, "nChunkSkips": 0, "millis": 406, "server": "mongotest:27017", "filterSet": false }
In the preceding JSON format, the n
field is an integer that reflects the number of affected records. Also, the indexOnly
field is Boolean and returns true
only when returned fields are already indexed.
Moreover, the millis
field is an integer...