I've noticed that all MongoDB ids that have been generated in my webapp so far start with the number 5. For example, 54fb5359b903f0340d000006 and 54fca4664679861c17000002. Why is that the case?
I've noticed that all MongoDB ids that have been generated in my webapp so far start with the number 5. For example, 54fb5359b903f0340d000006 and 54fca4664679861c17000002. Why is that the case?
Share Improve this question edited Sep 22, 2017 at 17:57 CommunityBot 11 silver badge asked Mar 9, 2015 at 21:40 Nathan L.Nathan L. 2532 silver badges10 bronze badges 1- now they all start with 6! Someday you can tell your kids you are old enough to remember when object IDs started with a 5. :) – Kip Commented Apr 1, 2022 at 14:18
1 Answer
Reset to default 12Mongo uses a specific algorithm to generate the IDs based on several underlying factors.
http://docs.mongodb/manual/reference/object-id/
For example, it looks like the first few bytes are a timestamp, something which will have the same first digit for quite some time.