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…
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
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)- A17% (5)
- B7% (2)
- C73% (22)
- D3% (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
Community Discussion
No community discussion yet for this question.
