Search code examples
mongodbazure-cosmosdbsharding

CosmosDB database-level throughput using MongoDB API no longer requires sharded collections?


A while ago I remember that I had to explicitly create my collections and define a shard key in order to use CosmosDB with MongoDB API with database-level throughput.

I see today that this does not seem necessary anymore. I turn on database-level throughput and run my code and unit tests without defining a shard key or anything and it all, so far, "just works". Searching for documentation on this I can't find anything. Are they just defining a shard key for me under the hood?

Not having to explicitly create collections with a shard key and not having to painstakingly modify all my queries to include a shard field that I don't really even need (there's nothing of any great size or need to scale in my scenario) would be wonderful. I always thought it was a big bummer to be forced to do that JUST to change the cost model on the database. Adding to that needing to change functionality (you can't create a unique index with a hashed shard key, for example). Ugh.


Solution

  • Yes, we made this change when we launched 3.6 support. Agree it's not really documented but we mention it in our announcement blog post here.

    Thanks.