Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Prepare Azure environments for new workloads—subscriptions, networking, identity, and landing zones
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/services/cosmos-db/partitioning.md
1# Cosmos DB Partition Key Selection23## Good Partition Keys45A good partition key should have:67- **High cardinality** - Many distinct values8- **Even data distribution** - No hot partitions9- **Even request distribution** - Balanced workload10- **Used in most queries** - Enables efficient routing1112## Examples by Scenario1314| Scenario | Partition Key | Reason |15|----------|---------------|--------|16| User-centric data | `/userId` | Queries typically filter by user |17| Multi-tenant apps | `/tenantId` | Isolates tenant data |18| E-commerce orders | `/customerId` | Orders queried by customer |19| IoT telemetry | `/deviceId` | High cardinality, even distribution |2021## Hierarchical Partition Keys2223For complex scenarios, use hierarchical keys:2425```bicep26partitionKey: {27paths: ['/tenantId', '/userId']28kind: 'MultiHash'29}30```3132## Anti-Patterns3334Avoid these partition key choices:3536| Bad Choice | Problem |37|------------|---------|38| Timestamp | Creates hot partitions |39| Boolean values | Only 2 partitions |40| Low cardinality enums | Uneven distribution |41| Random GUID | Can't query efficiently |42