It's been 8 months since my last blog post of that nature and I think it's time for a new one. It is also my second most popular post so if you like them, I'll write them.

Let's go straight to the point. Here are 15 more things you should know about Cosmos DB.

  1. Cosmos DB always returns paged results. You can continue reading the rest of the pages by providing the continuation token that you got from the previous request.
  2. The MaxItemCount FeedOption property that you can provide for any request that returns results in Cosmos DB does NOT represent the total amount of documents that you will get back. It represents the maximum amount of items that a single page of results will return. This means that if you have 1000 documents in a collection and you set the MaxItemCount to 10, you won't get 10 documents back but 1000 documents in pages of 10.
  3. There is no performance difference between an index of type Hash and an index of type Range. The only difference is the index size.
  4. Selecting only the properties you need when you perform a query will reduce the response time and the cost of the request.
  5. The only thing currently that can run cross partition stored procedures is the Bulk Executor library. It achieves that by getting a map of all the partition key ranges and executing against each one of them.
  6. Cosmos DB supports two different pricing models. Reserved throughput at the database level and reserved throughput at the collection level. They both have a minimum of 400 RU/s each.
  7. The database level reserved throughput also allows you to specify dedicated provisioned throughput at the collection level. This throughput is not shared with the rest of the database and it has nothing to do with how many RU/s your database is provisioned on.
  8. Cosmos DB now supports Cross-Origin Resource Sharing (CORS).
  9. Azure Functions support a Cosmos DB trigger which is a wrapper around the Change Feed processor. It is the simplest and easiest way to listen for document changes and addition in a collection.
  10. You can only order by a single property at a time in Cosmos DB. Multiple property ordering is currently not supported but it's being worked on.
  11. Your partition key choice should be a property that you always have when you query your Cosmos DB collection.
  12. You should never have to do any cross partition queries as part of your application's normal workflow, so choose your partition key wisely.
  13. While using the Cosmos DB C# SDK, never synchronise your Cosmos DB retrieval calls. Things like .AsEnumerable().ToList() will synchronise a bunch of background operations that the SDK is doing and it will block your application. Instead, create a IDocumentQuery by calling the AsDocumentQuery() method and call the query.ExecuteNextAsync() method while(query.HasMoreResults).
  14. The best way to manage Cosmos DB using PowerShell is to use the unofficial Cosmos DB PowerShell module from Daniel Scott-Raynsford
  15. There is a C# library called Cosmonaut which will make the usage of Cosmos DB in your C# application insanely straightforward. Give it a go.