sharding - Mongodb choose shard key -


i have mongodb collection want shard. collection holds messages users , document collection has following properties

{      _id : objectid,      conversationid: objectid,      created: datetime          } 

all queries done using converstionid property , sorter created.

  • sharding _id won't work because need query conversationid (plus _id of type objectid won't scale many inserts)

  • sharding conversationid logical choice in terms of query isolation i'm afraid won't scale many inserts (even if use hashed shard key on conversationid or if change type of property objectid other type isn't incremental guid) because conversation might more active others (i.e.: have many more message added them)

from see in mongo documentation the shard key either indexed field or indexed compound field exists in every document in collection.

does mean can create shard key on compound index ?

bottom line that:

  • creating hashed shard key _id property offer distribution of data

  • creating shard key on conversationid offer query isolation

so combination of these 2 things great, if done.

any ideas?

thanks

for case, neither of fields choice sharding. instance, if shard on conversationid, result in hot spotting, i.e. of inserts happen last shard conversationid monotonically increase on time. same problem other 2 fields well.

also, conversationid not offer high degree of isolation conversationid monotonically increase on time. (since newer conversations updated more old ones)

in case, "hashed shard key"(version 2.4 onwards) on conversationid smart choice 1 imagine there can tons of conversations going on in parallel.

refer following link details on creating hashed shard key: [ http://docs.mongodb.org/manual/tutorial/shard-collection-with-a-hashed-shard-key/ ]


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -