tlt
tlt

Reputation: 15211

Does the number of documents in the container unrelated to query affect RU cost?

Lets assume:

  1. there is a logical partition that contains 1000 documents
  2. there is a query that touches only that, single logical partition
  3. query yields 10 results

Question: Does the exact same query cost the same if there are 10,000 or 10,000,000 of documents within the container in other logical partitions that are not touched by the query?

Upvotes: 1

Views: 139

Answers (1)

Mark Brown
Mark Brown

Reputation: 8763

It depends. Generally speaking if your queries are properly utilizing the indexes the query should cost the same regardless of how much data there is in the container (assuming single partition query).

However, if your query performs a full scan on the data then the more data in the container, the more expensive the query for the same amount of results returned. You can learn more here in this Index Usage article.

You can now get metrics on whether you are using the right indexes in Cosmos DB in your queries. To learn more on how to enable and use these see, Indexing metrics in Azure Cosmos DB

Upvotes: 2

Related Questions