A .NET application uses an Azure Cosmos DB for NoSQL container named product with the partition key path /categoryId. The container has 60,000 RU/s of manual provisioned throughput, stores about 300 GB, and the Physical Partition Count metric shows eight physical partitions.
The category page runs the query SELECT * FROM c WHERE c.price > @floor. The page needs only products from the category being viewed, and it always knows that category's categoryId value. Today the application discards items from other categories after the query returns.
You must reduce the request charge of each execution and lower end-to-end latency. The partition key must not change, and you must not create additional containers.
Which change should you make?
Without the partition key value, the query fans out to all eight physical partitions, paying a small fixed charge in each and forcing the client to merge results from every partition. Passing the known categoryId through the request options routes the query to a single partition, which removes that overhead and the cross-partition merge, so both request charge and latency drop. More throughput or higher concurrency leaves the fan-out in place, and a global secondary index breaks the no-new-containers constraint and would not help a range filter.
- Correct: Set
QueryRequestOptions.PartitionKeyto the category ID. Supplying the partition key value in the request options scopes the query to one partition, so it avoids the per-partition fixed charge on the other seven partitions and the client-side merge across them, lowering both charge and latency without new containers or a key change. - Not correct: Increase the container's throughput to 80,000 RU/s. The query still fans out to every partition, and the client still merges results from each one, which adds latency that provisioned throughput does not remove; the per-execution charge is also unchanged.
- Not correct: Add a global secondary index partitioned on
/price. A global secondary index is an additional container with a different partition key, which the constraints forbid; also, a range filter such asc.price > @floorstill fans out even when the filtered property is the partition key. - Not correct: Set
MaxConcurrencyinQueryRequestOptionsto 8. Raising parallelism is a tuning step for queries that must span partitions and primarily targets latency; the query still visits all eight partitions and pays the per-partition charge on each.