Querying indexes in mongoid
Just wondering, if I index a field in mongoid is there a special query form I should be using to speed up queries using that 开发者_运维百科index or does Class.where(index: value) utilize that automatically?
I quote the creator of the Mongoid ODM from the following bug report in GitHub https://github.com/mongoid/mongoid/issues/1276
If you have fields that are indexed then it's determined on the database side if the index is to be used - there's nothing special on the Mongoid side of things when using criteria to provide index hints. Please remember though if you created the index in Mongoid to run rake db:create_indexes to ensure it actually got created in the db.
精彩评论