Connect to and consume Azure services and third-party services →mediumMultiple ChoiceObjective-mapped
AZ-204 Practice Question: Connect to and consume Azure services and third-party services
Your application uses Azure Cosmos DB for NoSQL. You need to query items by a property that is not the partition key. The container has 10,000 RU/s. How can you optimize this query to minimize cost and latency?
⚠ Common exam trap
Many exam-takers assume increasing RU/s (Option A) is the only way to handle cross-partition queries, but the exam tests the understanding that indexing strategy—specifically composite indexes—can eliminate the need for cross-partition fan-out, which is a more cost-effective and latency-optimizing approach.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Create a composite index that includes the property and the partition key.
Creating a composite index that includes the queried property and the partition key allows the query to be served efficiently from a single physical partition, avoiding a costly cross-partition fan-out. This reduces both RU consumption and latency, as the query can use the index without scanning all partitions.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Increase the RU/s to handle cross-partition queries.
Why it's wrong here
Increasing RU/s provides more throughput capacity for your Cosmos DB container, which can help queries complete faster by allowing more operations per second. However, it does not fundamentally improve the efficiency or index utilization of a poorly optimized cross-partition query. Without proper indexing, the query will still perform a full scan across partitions, consuming a high number of RUs, just with a higher ceiling for that consumption.
- ✓
Create a composite index that includes the property and the partition key.
Why this is correct
Creating a composite index that includes both the queried property and the partition key is crucial for optimizing cross-partition queries. This index allows the Cosmos DB query engine to efficiently seek and filter documents within each partition based on the specified property, rather than performing a full scan of all documents across all partitions. This significantly reduces RU consumption and improves query latency by leveraging the index for efficient data retrieval.
- ✗
Change the partition key to the property you query on.
Why it's wrong here
Changing the partition key of an existing Azure Cosmos DB container is not a direct solution as it requires recreating the container and migrating all existing data. This is a significant operational undertaking that impacts application availability and data integrity. While a well-chosen partition key is vital for new containers, altering it for an existing one is a disruptive and often impractical approach solely for query optimization.
- ✗
Enable analytical store and use Synapse Link.
Why it's wrong here
Enabling analytical store and utilizing Azure Synapse Link is designed for large-scale analytical workloads (OLAP) that require complex queries over operational data without impacting transactional performance. This solution creates a separate columnar store optimized for analytics. It is not intended for optimizing real-time, transactional queries (OLTP) directly against the core Cosmos DB transactional store, which is the context for improving immediate application query performance.
Go deeper
Related to this question
About these practice questions
This AZ-204 question is part of Courseiva's 881-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AZ-204 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-204 exam.