2

When you are working with the RavenDB in a sharded environment, the document ids will include the shard id such as europe/companies/21. It's also documented on the RavenDB site:

ModifyDocumentId: lets you store the shard id for a document in the document itself. The default implementation is: (convention, shardId, documentId) => shardId + convention.IdentityPartsSeparator + documentId

By doing that, I am guessing RavenDB is figuring out smart querying techniques and can specifically target the proper shard which is great. However, I have a few questions which I am unable to answer:

  • How about if I need to move a document to a new shard? That would change the key and break URLs that have used the key as asked here.

  • I may start with only one server and then later, I may decide to implement sharding. So, in that case the keys will change (?) or smart querying will not work (?).

What are the general advises on those concerns and how are these problems are solved?

Community
  • 1
  • 1
tugberk
  • 57,477
  • 67
  • 243
  • 335

1 Answers1

1

If you move a document between shards, you need to modify the sharding function to be aware of it. RavenDB is okay if a document may reside on multiple shards, you just have to make sure it is not on multiple shards concurrently.

If you start with just one server, I suggest still doing sharding, on different dbs on the same server.

Ayende Rahien
  • 22,925
  • 1
  • 36
  • 41
  • Thanks for the answer. Is there anyway to change the id generation on sharded environment? I would like my ids to look like `countries/1001` where the first 3 digits are the shard id. In our case here, shard id is 100 and document id is 1. – tugberk Jun 24 '13 at 10:05
  • Yes, you can do that, look at the ModifyDocumentId on the ShardStrategy – Ayende Rahien Jun 24 '13 at 14:29