Question 7
UnclassifiedA Cosmos DB container stores orders for many tenants. Queries almost always filter by tenant and order date. What should the developer consider first?
Correct answer: A
Explanation
Azure Cosmos DB partition keys should be chosen to match the main query pattern and avoid hot partitions. Because the workload “almost always filter[s] by tenant and order date,” a partition key that distributes data well and supports that tenant-scoped access pattern reduces cross-partition queries and improves performance.
Why each option is right or wrong
A. A partition key that distributes data well and supports the dominant tenant-scoped access pattern.
Azure Cosmos DB requires every item to be assigned to a logical partition based on the partition key, and queries that include the partition key can be routed to a single partition instead of fan-out across many. In this workload, the dominant access pattern is tenant-scoped order lookups by date, so the first design decision is a partition key that aligns with that tenant-centric filter while still avoiding skew; otherwise, the container risks hot partitions and higher RU charges from cross-partition scans.
B. A partition key that always uses a constant value.
C. Removing the tenant identifier from every document.
D. Storing all orders in one large text field.