MongoDB ObjectID uniqueness in a Sharded Cluster -


if have mongodb sharded cluster multiple mongos instances, objectid in _id consistant whichever mongos write to?

for example, if write data mongos#1 , _id ascends normally, if write using mongos#2 these _id's ascend in line other writes?

seeing part of objectid based on machine hash , process id, can't see sorting on objectid useless. correct?

whats recomendation here?

how objectid generated give fair idea query.

if type in mongo console,

new objectid()

you see objectid sample value as

objectid("558bf61f9f49f303f72dd59b") 

now, lets break , see how mongo generates this. 558bf61f 9f49f3 03f7 2dd59b

  1. here first 8 characters (4 bytes) represents number of seconds (not milliseconds) timestamp.
  2. the next 3 bytes machine identifies.
  3. the next 2 bytes process id.
  4. and lastly 3-bytes random value.

http://api.mongodb.org/libbson/current/bson_oid_t.html

so, sure mongos connected with, time goes on in ascending order (because of first point) other points ensure unique number. hope clarifies doubt.

-$


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -