Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is not the MongoId 12-byte long but the 24-byte?

According to the official document:

A BSON ObjectID is a 12-byte value consisting of a 4-byte timestamp (seconds since epoch), a 3-byte machine id, a 2-byte process id, and a 3-byte counter

But actually it's a 24-byte value like 4d7f4787ac6d604009000000

Why does this happen ?

like image 869
Linuxd Avatar asked Feb 25 '23 19:02

Linuxd


1 Answers

That's a hexidecimal value. One hex digit = 4 bits. 24 hex digits = 96 bits = 12 bytes.

like image 82
Tyler Eaves Avatar answered Mar 03 '23 02:03

Tyler Eaves