Articles Tagged pymongo

Timestamp and ObjectId in mongoDB

Timestamp and ObjectId from mongoDB

Every record in mongoDB has field _id, that must be unique inside collection. By default type of this field is ObjectId, and it is assigned automatically if field is not set.

Lets look at ObjectId more carefully.
It is 12 bytes that includes:

  • a 4-byte value representing the seconds since the Unix epoch,
  • a 3-byte machine identifier,
  • a 2-byte process id, and
  • a 3-byte counter, starting with a random value.

As we see, first 4 ...

Posted on 2015-01-18