nerdexam
Microsoft

DP-420 · Question #68

You have a database named db1 in an Azure Cosmos DB for NoSQL account. You are designing an application that will use db1. In db1, you are creating a new container named coll1 that will store online…

The correct answer is B. customerId. Using customerId as the partition key is optimal here for two reasons: (1) all orders for a given customer are co-located in the same logical partition, so queries for a customer's order history are single-partition (efficient and cheap); (2) with many customers placing orders…

Design and implement data distribution

Question

You have a database named db1 in an Azure Cosmos DB for NoSQL account. You are designing an application that will use db1. In db1, you are creating a new container named coll1 that will store online orders. The following is a sample of a document that will be stored in coll1. The application will have the following characteristics:

  • New orders will be created frequently by different customers.
  • Customers will often view their past order history.

You need to select the partition key value for coll1 to support the application. The solution must minimize costs. To what should you set the partition key?

Exhibit

DP-420 question #68 exhibit

Options

  • AorderId
  • BcustomerId
  • CorderDate
  • Did

How the community answered

(55 responses)
  • A
    2% (1)
  • B
    84% (46)
  • C
    9% (5)
  • D
    5% (3)

Explanation

Using customerId as the partition key is optimal here for two reasons: (1) all orders for a given customer are co-located in the same logical partition, so queries for a customer's order history are single-partition (efficient and cheap); (2) with many customers placing orders, the data and throughput load is distributed across many partitions, avoiding hot partitions. orderId distributes evenly but forces cross-partition queries for order history. orderDate creates hot partitions because recent dates receive all new writes. id is essentially the same as orderId in terms of partition behavior.

Topics

#Azure Cosmos DB#Partition Key#Cost Optimization#Query Optimization

Community Discussion

No community discussion yet for this question.

Full DP-420 Practice