For a project I'm considering the use of Cosmos DB (SQL API) as my database solution. Reading the docs about the Request Units, I learned here and here that reading 1 item of size 1 KB takes up 1 RU (Request Unit).
When I execute the query below (where I query all items within a single partition (gender is the PartitionKey), I get a result of 5.000 items (in five chunks of 1.000 items). Each item is 1.5 KB in size, so should be even more that 1 RU per item. However, the header states that the RequestCharge
is only 88.12 in total, for 1.000 items. Following the rule of 1 RU per item of size 1 KB I was expecting at least 1000 RU.
Does anybody know how to interpret the RequestCharge
correctly?
Code and query:
public async Task<List<Profile>> GetAllProfilesByGender(string gender)
{
var container = GetContainer();
var queryIterator = GetQueryIterator(container, gender);
var profiles = new List<Profile>();
while (queryIterator.HasMoreResults)
{
var resultSet = await queryIterator.ReadNextAsync();
foreach (var profile in resultSet)
{
profiles.Add(profile);
}
}
return profiles;
}
private FeedIterator<Profile> GetQueryIterator(Container container, string gender)
{
var query = new QueryDefinition($"SELECT * FROM c WHERE c.Gender = '{gender}'");
return container.GetItemQueryIterator<Profile>(query);
}