0

If I do create a hashed index with ensureIndex({ _id: "hashed"}) will Mongo know to take any queries on the _id field and run them against the hashed index? Or do I need to update all the queries that use _id to be the _id_hashed?

1
  • 2
    when you create id:"hashed" index, it's _in addition to regular _id:1 index. Nov 23, 2013 at 1:33

1 Answer 1

1

Mongodb doesn't modify the _id field when a hashed index is created. It will do the right thing, and query against _id appropriately. The hash will only be used to query and balance the shards.

1
  • Is there a way to replace the existing "_id":1 index with "_id":"hashed" ? I have created an hashed index but the default id index still exists which takes up disk space and RAM.
    – ankshah
    Jul 24, 2017 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.