liveBook · Manning

Partitioning key

As explained in Microsoft Azure in Action

A partition key is the entity-key component that identifies the physical partition in which an Azure Table Storage entity is stored.

A partition key helps decide where data lives. In Azure Table Storage, it identifies the physical partition for an entity and forms one half of that entity’s unique identifier. The row key identifies the entity within its partition; together, the two keys identify it within the table. Azure can move a partition to another machine when it faces high load or needs more space. section 5.6.2

PS C:\>Add-AzTableRow -table $cloudTable -partitionKey 'bookkey1' 
-rowKey ((New-Guid).Guid) -property @{"title"="Azure in Action";"bookid"=1}

This PowerShell insertion gives an entity the partition key `bookkey1`, a GUID row key, and two properties. The partition key is not the book’s title or the whole unique identifier. section 5.6.2

Partition-key choice also matters in Azure Cosmos DB. For an online store, using `category` groups items in the same category so queries can locate them quickly. But a key that concentrates too much data or too many requests in one partition can create a performance bottleneck—a hot partition. section 11.3.2

Choose a key with both distribution and common queries in mind:

  • Look for many distinct values so data and requests spread across partitions. section 11.3.2
  • If queries commonly filter by region, a region key can make them more efficient—but only if the resulting load is reasonably balanced. section 11.3.3
  • Consider a combined key such as region-category when one attribute alone risks a hotspot. Queries spanning partitions can cost more request units and take longer. section 11.3.3

How Microsoft Azure in Action covers it

How deep it goes
Defines the Table Storage identifier and works through Cosmos DB selection trade-offs, while deferring deeper Table Storage partition planning.
Examples
Uses a PowerShell table-row insertion and an online-store category key to show entity identity and data grouping.
What it assumes
Introduces partition and row keys from their roles, then assumes a table reference and storage context for the PowerShell insertion.
What you can do after
Apply it via Add-AzTableRow for Table Storage and evaluate Cosmos DB keys against load distribution and query patterns.
How it connects
Connects partition keys to row keys, hot partitions, high cardinality, composite keys, and cross-partition queries.

Also explained in

Compare how 10 books explain partitioning key →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microsoft Azure in Action. The section links point to the parts of the book it draws on.