|Re-defining objectId for better shardability||Georg Koester||2/25/12 1:10 PM|
I was starting work on a new project and I would like to design
sharding into my setup from the start. Therefore I want to create my
own objectId with a month-prefix and a different order. I did some
development and can provide the code - basically used the bson
objectId Java class as template.
Could you hint how I can ensure that serialization uses the binary
format of objectids in the db?
|Re: [mongodb-user] Re-defining objectId for better shardability||Scott Hernandez||2/25/12 2:22 PM|
You cannot change the data in an objectid. It is a defined type. You can define your own binary field if you want, and store it as the _id field.
|Re: Re-defining objectId for better shardability||Georg Koester||2/26/12 4:46 AM|
thanks for the hint! I implemented that and It's quite ok. I
understand that there's a 4 byte overhead for the length attribute and
that I could rewrite my own object id generator with a different order
of the parts that are composed to the 12 byte id, too, if I wanted
better write distribution with smaller indexes/tables. I'm going to do
that, too. That'll be a nice id toolbox!
For reference: Digging deeper I found a very good discussion of the