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…
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
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)- A76% (13)
- B6% (1)
- C12% (2)
- D6% (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
Community Discussion
No community discussion yet for this question.
