explain:
With this command you can figure out how to execute the query mongodb
db.the_table.find({"age":{"$gte":0}}).explain("executionStats")
totalKeysExamined entire scan display index number is 0, docsExamined display 9 to scan the entire set of documents
You can create an index with ensureIndex () or createIndex (), which the old version with ensureIndex ()
getIndexes () method checks whether the index is successfully created:
(Collection now has two indexes: the first is the standard _id index; the second is our num index created index names are called _id_ and num_1.)
After setting the index view will change with explain:
db.numbers.find({num:{"$gt":19995}}).explain("executionStats")