Re-defining objectId for better shardability

Showing 1-3 of 3 messages
Re-defining objectId for better shardability Georg Koester 2/25/12 1:10 PM
Hi all,

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?

Go mongo!
Georg
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.

--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.

Re: Re-defining objectId for better shardability Georg Koester 2/26/12 4:46 AM
Hi Scott,

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
topic in
http://groups.google.com/group/mongodb-user/browse_thread/thread/5108572d262e355f

Cheers all,
Georg


On 25 Feb., 23:22, Scott Hernandez <scotthernan...@gmail.com> wrote:
> 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.