Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do all Object IDs in MongoDB start with the number 5?

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?

like image 425
Nathan L. Avatar asked Mar 09 '15 21:03

Nathan L.


1 Answers

Mongo uses a specific algorithm to generate the IDs based on several underlying factors.

http://docs.mongodb.org/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.

like image 68
Tim Avatar answered Oct 13 '22 02:10

Tim