MattCowen
MattCowen

Reputation: 175

Hashed shard key in MongoDB on the _id so then what?

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?

Upvotes: 0

Views: 1739

Answers (1)

idbentley
idbentley

Reputation: 4218

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.

Upvotes: 1

Related Questions