Reducing RU Consumption in Azure Cosmos DB for NoSQL
Short answer
B Configure selective indexing on queried properties to exclude unused fields and reduce write RU costs.
Question
Each document contains 30 properties. Queries filter only on deviceId and timestamp.
Write operations consume more RUs than expected.
You need to reduce RU consumption for write operations while maintaining query performance.
What should you do?
Key Takeaways
The question tests the trade-off between index size and write overhead; the common trap is assuming all default indexes are necessary for query performance.
Optimize write performance in Azure Cosmos DB for NoSQL by configuring selective indexing to exclude unused properties. This approach reduces Request Unit (RU) costs while maintaining query efficiency on filtered fields.
Common mistake: Users often select 'Enable strong consistency' or 'Migrate partition key', failing to recognize that these actions do not address the specific overhead caused by maintaining unnecessary indexes.
Expert Analysis
Why the Answer Is Correct
Azure Cosmos DB for NoSQL automatically indexes all properties by default, which significantly increases the RU cost of write operations as every property update requires index maintenance. By configuring selective indexing (Option B), you can explicitly define which properties to index—specifically 'deviceId' and 'timestamp' in this scenario—and exclude the other 27 unused properties. This directly reduces the storage footprint and the computational overhead during writes, achieving the goal of lower RU consumption without impacting the required query performance.
Why the Other Options Are Wrong
Option A is technically similar but less precise; 'selective indexing' is the standard configuration method to achieve exclusion, making B the superior architectural answer. Option C addresses data distribution and hot partitions but does not reduce the per-document index overhead. Option D increases consistency checks, which typically raises RU consumption rather than reducing it.
Community Comment Notes
Community feedback confirms that since queries only filter on two properties, indexing all 30 is wasteful. As noted by user sanitest, "Because your queries only filter on deviceId and timestamp, there is no benefit in indexing all 30 properties." This aligns with the best practice of minimizing indexed paths to optimize write throughput.
Exam Strategy
Always analyze the query patterns first. If a document has many properties but queries only use a few, configure selective indexing to minimize write overhead.
Frequently Asked Questions
Why does indexing all properties increase write RUs?
Does selective indexing affect query speed?
Discussion 1 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 1
-
sanitest 👍 1 Answered BBecause your queries only filter on deviceId and timestamp, there is no benefit in indexing all 30 properties. Azure Cosmos DB's default policy indexes every property, which increases the RU cost of every write because the indexes must be updated for each indexed field.
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.