What’s the difference between Logical and Physical partitions in Cosmos DB?

In Cosmos DB, logical and physical partitions are two different aspects of the storage and organization of data within a container:

Logical Partition:

  • A logical partition in Cosmos DB is a unit of data organization within a container.
  • It represents a subset of the data stored in the container and is defined based on a chosen partition key.
  • All items with the same partition key value are stored together within the same logical partition.
  • Logical partitions provide a way to group related data and enable efficient querying and transactions within that subset of data.
  • Operations performed within a logical partition are executed in an atomic, consistent, isolated, and durable (ACID) manner.

Physical Partition:

  • A physical partition in Cosmos DB is the underlying storage unit where the data is physically stored.
  • It represents a portion of the storage capacity within a container.
  • The number of physical partitions is managed automatically by Cosmos DB based on factors such as the throughput requirements and storage size of the container.
  • Each physical partition can store multiple logical partitions, and the logical partitions within a container are distributed across multiple physical partitions.
  • Physical partitions allow Cosmos DB to scale horizontally by distributing data and workload across multiple storage units, enabling high throughput and performance.

In summary, logical partitions are subsets of data defined by the chosen partition key within a container, while physical partitions are the actual storage units where the data is physically stored. Logical partitions group related data for efficient querying, while physical partitions enable scalability and parallel processing by distributing data across multiple storage units.

error: Content is protected !!