Nischala Reddy
Nischala Reddy

Reputation: 61

How to reduce the RequestCharge to 1RUs while reading data from query in azure cosmos DocumentDB

enter image description here enter image description here

I want to make that 2.28RUs to 1RUs by changing my query,can anyone help me out?

Upvotes: 1

Views: 174

Answers (1)

David Makogon
David Makogon

Reputation: 71066

You cannot magically make a query cost 1 RU. I'm pretty sure you won't be able to, as you're utilizing the query engine. You might be able to reduce RU a bit by just returning the properties you need (vs returning *).

You can reduce RU a bit at write time by excluding properties from being indexed, when you know you won't be searching by those properties.

But to reduce RU cost during retrieval, you'll need to do a direct read, vs a query. This requires an API/SDK call, and cannot be executed via the query explorer. In c#, this would look something like;

var response = 
  await client.ReadDocumentAsync(UriFactory.CreateDocumentUri(dbId, collectionId, docId));

You can then inspect response.RequestCharge to see what this cost in RU (and it should be lower than the query cost).

Upvotes: 4

Related Questions