juniorCosmos DB

What is a Partition Key in Cosmos DB?

Updated Feb 20, 2026

Short answer

A partition key in Azure Cosmos DB is a field used to distribute data across multiple physical partitions for scalability and performance.

Deep explanation

Cosmos DB stores data in logical partitions based on the partition key value. Each partition holds a subset of data. This allows the database to scale horizontally.

When you choose a good partition key, queries and writes are evenly distributed. A bad partition key can cause “hot partitions,” where too much data or traffic goes to one partition, reducing performance.

Real-world example

In an e-commerce system, “CustomerID” can be a partition key. All orders from a customer are grouped together, but data is still spread across many partitions for scalability.

Common mistakes

  • - Choosing low-cardinality keys like “country.”
  • - Not considering query patterns when selecting partition keys.
  • - Creating uneven data distribution (hot partitions).

Follow-up questions

  • What is a hot partition?
  • Can partition keys be changed later?
  • How does partitioning affect performance?

More Cosmos DB interview questions

View all →