Soru

Zorluk: KolayConfigure Partition Keys and Partitioning Strategies in Azure Cosmos DB

You are designing an Azure Cosmos DB container to store customer order records for an online retail application. Each order document contains `OrderId`, `CustomerId`, `OrderDate`, and `ShippingStatus`. The application frequently queries orders for a given customer and requires transactional updates when modifying multiple orders for the same customer.

Which two requirements are satisfied by selecting `CustomerId` as the partition key for this container?

  1. It enables multi-document transactions using transactional batches or stored procedures for orders belonging to the same customer.Cevap
  2. It ensures that queries filtering by the customer identifier to retrieve order history are served as single-partition queries.Cevap
  3. C
    It guarantees that a single logical partition will never exceed the 20 GB storage limit, regardless of the volume of orders per customer.
  4. D
    It automatically implements Session consistency across multiple independent client sessions without needing to pass a session token.

Cevap

Selecting the customer identifier as the partition key satisfies the requirements by enabling multi-document transactions for orders within the same customer scope and ensuring that customer history queries are single-partition queries.
Selecting the customer identifier as the partition key ensures all orders for a single customer reside in the same logical partition. This enables transaction execution (stored procedures, transactional batch) across those documents and allows the database to route customer-specific queries to a single partition, minimizing Request Unit (RU) consumption.

Adım Adım Çözüm

1
Analyze transactional requirements.
Since transactions in Azure Cosmos DB are scoped to a single logical partition, partitioning by customer identifier puts all of a customer's orders in the same logical partition, allowing transaction execution.
Azure Cosmos DB requires all items participating in a transaction to share the same partition key value.
2
Analyze query patterns.
Queries filtering by customer identifier will target a single logical partition.
Providing the partition key in the query filter allows the Azure Cosmos DB SDK to route the query directly to the correct partition, optimizing Request Unit consumption.
3
Evaluate limits and consistency constraints.
Identify that partitioning does not prevent a logical partition from growing beyond 20 GB if a single partition key value accumulates too much data, and does not configure session consistency.
Logical partitions are limited to 20 GB, and session consistency requires session token management.

Anahtar Kavram

Selecting an appropriate partition key in Azure Cosmos DB is essential for maintaining transactional boundaries and optimizing query performance.
Tahmini Süre:1m 0s
Bu soruyu puanla