Fixed collections deprecated

Just happened to notice on the Azure Portal, that Microsoft is moving to deprecate fixed collections in Azure Cosmos DB. Click on the image to make it bigger and have a look. This is really good news!

In my opinion, you should hardly ever create fixed containers. Maybe for some quick testing or similar. You can read more about this in my Cosmos DB tutorial I published earlier this year on GitHub. Always go with partitioned collections, right from the start.

I’ll explain why I think it’s good that fixed collections are becoming distinct.

Why Fixed Collections Are Bad for You

Size Limit

The maximum amount of data that can be stored in a fixed collection is 10 GB. That is the size limit of one partition, even in partitioned collections. However, you can have an unlimited number of partitions in a partitioned collection. A fixed collection is restricted to one single partition. This also means that 10 GB is the maximum amount of data you can store in a fixed collection.

Code Changes

The code you write to access data in a fixed collection is slightly different from the code you use to access a partitioned collection.

When running queries against your Cosmos DB collection, you either specify the partition key to scope your query to a single partition, or execute a cross-partition query (which might have some performance implications), or cross your fingers and hope that your query result produces only documents from a single partition.

This is something that you don’t do when querying fixed collections, since there is no partition key to specify in the query, nor can you run cross-partition queries when you have only one partition.

Changing from Fixed to Partitioned Collection Requires Extra Work

To move from a fixed collection to a partitioned collection typically means changes to both your code and data.

The first project I did with Cosmos DB, I just fired up a fixed collection, and started creating my data access code for that collection. I ended up doing some code refactoring when I realized that I had to change to a partitioned collection.

Once a collection has been created, it cannot be changed from a fixed collection to a partitioned collection. So I had to create a new collection, and migrate my data. I also had to make sure that all documents stored in the collection so far had meaningful values in the attribute i chose as partition key.

All of this time it took to refactor and migrate, I could have used on actually developing the application, instead of refactoring, if I would have known this beforehand.

Final Thoughts

I warmly welcome this update to Cosmos DB. If you ask me, Microsoft should never have added the fixed collections option to Cosmos DB. Luckily Microsoft now is changing this.

If you’re new to Azure Cosmos DB or just want to learn more about it, head over to the documentation for Azure Cosmos DB.


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *