DP-420 · Question #18
The following is a sample of a document in orders. The orders container uses customerId as the partition key. You need to provide a report of the total items ordered per month by item type. The…
The correct answer is B. Configure the report to query a new aggregate container. Populate the aggregates by using the. Running aggregation queries (total items per month by item type) directly against the raw 'orders' container requires scanning large volumes of documents across multiple partitions - especially since the partition key is 'customerId', not 'itemType' or 'date'. This is expensive…
Question
The following is a sample of a document in orders. The orders container uses customerId as the partition key. You need to provide a report of the total items ordered per month by item type. The solution must meet the following requirements:
- Ensure that the report can run as quickly as possible.
- Minimize the consumption of request units (RUs).
What should you do?
Exhibit
Options
- AConfigure the report to query orders by using a SQL query.
- BConfigure the report to query a new aggregate container. Populate the aggregates by using the
- CConfigure the report to query orders by using a SQL query through a dedicated gateway.
- DConfigure the report to query a new aggregate container. Populate the aggregates by using SQL
How the community answered
(35 responses)- A6% (2)
- B80% (28)
- C11% (4)
- D3% (1)
Explanation
Running aggregation queries (total items per month by item type) directly against the raw 'orders' container requires scanning large volumes of documents across multiple partitions - especially since the partition key is 'customerId', not 'itemType' or 'date'. This is expensive in RU/s and slow. The optimal solution is to maintain a separate aggregate container pre-computed from the raw data. The Azure Cosmos DB change feed is ideal for populating this aggregate container in near real-time: every time an order document changes, a change feed processor updates the aggregate. When the report runs, it queries the small, pre-aggregated container, resulting in minimal RU consumption and maximum speed. Option D (SQL queries) cannot produce continuous, incremental aggregates the way the change feed can.
Topics
Community Discussion
No community discussion yet for this question.
