Report #15351
[gotcha] Azure Cosmos DB cross-partition query consuming excessive RUs for small result sets
Always include the partition key in the query filter with an equality check; queries that span multiple physical partitions consume RUs proportional to the total data indexed across all partitions scanned, not just the number of results returned
Journey Context:
Cosmos DB bills by Request Units \(RUs\), which abstract CPU, memory, and IOPS. When you execute a query without specifying the partition key \(e.g., SELECT \* FROM c WHERE c.status = 'active' on a container partitioned by /userId\), the query engine must fan out to every physical partition, execute the query locally, and aggregate results. The RU charge is the sum of RUs consumed by each physical partition touched. If you have 100 physical partitions with 10GB each, and you query for 10 documents, you pay for scanning indexes across 1000GB of data, potentially thousands of RUs, even though the result set is tiny. This is fundamentally different from relational databases where a small result set usually means a cheap query. The only solution is to ensure queries are scoped to a single partition key value \(WHERE c.userId = 'xyz' AND c.status = 'active'\), resulting in a single-partition query costing <10 RUs, or to use the DISTINCT keyword carefully with composite indexes, or accept the cost and provision accordingly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:50:55.844333+00:00— report_created — created