nr1kqg
Last Updated: February 25, 2016
·
1.619K
· squiter85
5f93e10abd0998d0c7e6d3ae32da7b83

Force mongo to use a specific index

MongoDB automatically choose what index it uses in determinated queries, but you can specify what index you want mongoDB uses.
To specify the index, you can use the hint() method after your query:

db.users.find().hint({name:1})

You can force mongo to do not use any index too:

db.users.find().hint({$natural:1})
Say Thanks
Respond