nerdexam
Microsoft

DP-420 · Question #91

You have an application that queries an Azure Cosmos DB for NoSQL account. You discover that the following two queries run frequently. You need to minimize the request units (RUs) consumed by reads…

The correct answer is C. a composite index for (name ASC, timestamp ASC). Cosmos DB requires a composite index to efficiently serve ORDER BY clauses that reference multiple properties. A composite index defined as (name ASC, timestamp ASC) supports queries ordered name ASC, timestamp ASC as well as queries ordered name DESC, timestamp DESC (the full…

Optimize an Azure Cosmos DB solution

Question

You have an application that queries an Azure Cosmos DB for NoSQL account. You discover that the following two queries run frequently. You need to minimize the request units (RUs) consumed by reads and writes. What should you create?

Exhibit

DP-420 question #91 exhibit

Options

  • Aa composite index for (name DESC, timestamp ASC)
  • Ba composite index for (name ASC, timestamp ASC) and a composite index for (name DESC,
  • Ca composite index for (name ASC, timestamp ASC)
  • Da composite index for (name ASC, timestamp DESC)

How the community answered

(30 responses)
  • A
    17% (5)
  • B
    7% (2)
  • C
    73% (22)
  • D
    3% (1)

Explanation

Cosmos DB requires a composite index to efficiently serve ORDER BY clauses that reference multiple properties. A composite index defined as (name ASC, timestamp ASC) supports queries ordered name ASC, timestamp ASC as well as queries ordered name DESC, timestamp DESC (the full reverse of the index is automatically usable). Creating only one composite index minimizes the write overhead (each additional index consumes additional RUs on writes). A single (name ASC, timestamp ASC) composite index is sufficient for the two queries described (one using ascending order, one using descending order of the same fields), making option C the most efficient choice.

Topics

#Composite Index#Request Units#Query Optimization#Order By

Community Discussion

No community discussion yet for this question.

Full DP-420 Practice