发布于 2015-09-14 15:07:03 | 167 次阅读 | 评论: 0 | 来源: 网络整理
The $hint operator forces the query optimizer to use a specific index to fulfill the query. Use $hint for testing query performance and indexing strategies. Consider the following form:
db.collection.find().hint( { age: 1 } )
This operation returns all documents in the collection named collection using the index on the age field. Use this operator to override MongoDB’s default index selection process and pick indexes manually.
You can also specify the option in either of the following forms:
db.collection.find()._addSpecial( "$hint", { age : 1 } )
db.collection.find( { $query: {}, $hint: { age : 1 } } )