Chris Bolton
Chris Bolton

Reputation: 2926

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?

Upvotes: 0

Views: 393

Answers (1)

3en
3en

Reputation: 219

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.

Upvotes: 1

Related Questions