nerdexam
Microsoft

DP-420 · Question #31

You have the following query. You need to recommend a composite index strategy that will minimize the request units (RUs) consumed by the query. What should you recommend?

The correct answer is A. a composite index for (sensor ASC, value ASC) and a composite index for (sensor ASC. The correct answer is A: a composite index for (sensor ASC, value ASC) and a composite index for (sensor ASC, ...). In Azure Cosmos DB, composite indexes are needed when a query contains both a filter and an ORDER BY clause, or multiple range filters. When a query filters on…

Optimize an Azure Cosmos DB solution

Question

You have the following query. You need to recommend a composite index strategy that will minimize the request units (RUs) consumed by the query. What should you recommend?

Exhibit

DP-420 question #31 exhibit

Options

  • Aa composite index for (sensor ASC, value ASC) and a composite index for (sensor ASC,
  • Ba composite index for (sensor ASC, value ASC, timestamp ASC) and a composite index for
  • Ca composite index for (value ASC, sensor ASC) and a composite index for (timestamp ASC,
  • Da composite index for (sensor ASC, value ASC, timestamp ASC)

How the community answered

(17 responses)
  • A
    76% (13)
  • B
    6% (1)
  • C
    12% (2)
  • D
    6% (1)

Explanation

The correct answer is A: a composite index for (sensor ASC, value ASC) and a composite index for (sensor ASC, ...). In Azure Cosmos DB, composite indexes are needed when a query contains both a filter and an ORDER BY clause, or multiple range filters. When a query filters on 'sensor' and 'value' while ordering by 'timestamp', two separate composite indexes - one covering the filter fields and one covering the sort path - allow the engine to satisfy both ascending and descending sort orders efficiently without a full scan. Adding 'timestamp' to a single composite index (Options B, D) is unnecessary and wasteful. Option C places 'value' before 'sensor', which breaks index prefix matching for queries that filter on 'sensor' first.

Topics

#Composite Indexes#Query Optimization#Request Units#Azure Cosmos DB Performance

Community Discussion

No community discussion yet for this question.

Full DP-420 Practice