albattran
albattran

Reputation: 1907

Azure CosmosDB Cost of 1 Get is not 1 RU

I am setting up a complex system with very high RU requirement, but trying to fine tune the query and indexes, but I could not figure out how to get RU = 1 for a single Get operation.

I created a single document in a test database as follows:

    {
        "id": "1",
        "key": "1",
    }

I set the consistency level to Eventual (which should have the lowest RU) I set no indexing and run this query:

SELECT * FROM c where c.id = "1" and c.key="1"

I always get Request Charge: 2.27 RUs. Am I doing something wrong? Thanks

Upvotes: 1

Views: 741

Answers (1)

Matias Quaranta
Matias Quaranta

Reputation: 15603

If you take a look at the official docs, it differentiates a Read from a Query.

A Read uses ~1 RU, but a Query ~2.5 RU (which is similar to what you are seeing).

To Read (using the Id) you can use the ReadDocumentAsync method in the SDK:

await yourDocDBSDKclient.ReadDocumentAsync(UriFactory.CreateDocumentUri(databaseName, collectionName, documentId));

There is also a section referring to Considerations that might help in improving your RU usage.

Upvotes: 2

Related Questions