Reducing RU Consumption in Azure Cosmos DB for NoSQL

Develop AI solutions by using Azure Cosmos DB for NoSQL
Answer Correct answer: B — Configure selective indexing on queried properties to exclude unused fields and reduce write RU costs.

You develop an AI application that stores telemetry documents in Azure Cosmos DB for NoSQL. 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?

  1. Exclude unused properties from indexing.
  2. Configure selective indexing on queried properties. Correct Answer
  3. Migrate to a different partition key.
  4. Enable strong consistency for all requests.

Community Insight

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.

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.

Community Discussion (1 comments)

sanitest 👍 1 Selected: B
Because 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.

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

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?

Cosmos DB updates secondary indexes for every property change. More indexed properties mean more work per write operation.

Does selective indexing affect query speed?

No, as long as you include all properties used in WHERE clauses or JOINs, query performance remains optimal.

More AI-200 FAQ →

Related Analysis

← Back to AI-200 Study Guide