According to the information you have provided, productCategoryID would be a better partition key choice. Partition keys are used by Azure Cosmos DB to distribute data and workload evenly across multiple physical partitions. The partition key you select determines data distribution and transaction scope. If you use productID as the partition key, each product will have its own partition. While this may be ideal for operations that only target a single product, it does not appear to correspond to your most common operation. If you use productCategoryID as the partition key, all products in the same category will be in the same partition. This will be more efficient for querying and transactions for operations involving groups of products from the same category.
Partition Key in cosmos DB
Hi,
If the most common operation will display a product catalog that has products grouped by product category.
Which property should I use for the partition key?
Is that productID or productCategoryID?
Thank you in advanced
2 answers
Sort by: Most helpful
-
-
Oury Ba-MSFT 20,716 Reputation points Microsoft Employee
2023-08-08T18:03:25.33+00:00 @Agnieszka Maria Mietz-Blijleven Thank you for reaching out.
in addition to @Sedat SALMAN
When choosing a partition key, it's important to consider the access patterns of your application. You should choose a partition key that is frequently used in queries and has a high cardinality. You should also choose a partition key that is immutable and has a small size.
If the most common operation is to display a product catalog that has products grouped by product category, then you should consider using the productCategoryID as the partition key.
Please read more here Partition key examples for a better understanding on partition key in Aure cosmos DB
Regards,
Oury