0

hashed indexes, if evenly distributed, has time complexity of O(1), while b tree index always has complexity of O(log(N)).

So the question is, is the ObjectId that MongoDB creates for the _id field be evenly distributed such that the time complexity is indeed O(1)?

  • The `_id` is a unique key, so the values cannot be evenly distributed. – Wernfried Domscheit Jan 29 '23 at 20:10
  • MongoDB stores all indexes in a b-tree, regardless of whether the valued is hashed or not. Check out https://stackoverflow.com/questions/28330170/mongodb-performance-difference-between-hash-and-ascending-indices-any-reason-no – Joe Feb 01 '23 at 01:55

0 Answers0