Reputation: 58
I'm confusing about the partition key with cosmos db. I have a database/container with about 4000 small records. If I try a sql statement with my partition key filter, the RUs and the duration time is larger then without.
Does someone understand this?
in this sample my partition key of the container is /partitionKey
I tried this statement: SELECT * FROM c where c.partitionKey = 'userSettings' And c.deleted =false
Request Charge 50 RUs Document load time 2.15 ms
and then this SELECT * FROM c where c.cosmosEntityName = 'userSettings' And c.deleted =false
Request Charge 5 RUs Document load time 0.38 ms
I expect exactly the opposite results.
Upvotes: 3
Views: 3494
Reputation: 8003
This question is very specific to the topology of your collection (which Azure support can help with), but generally speaking there are two cases where the latter query on non-partition key property can be lower in RUs than the partition key property:
List item
where c.partitionKey = 'userSettings' And c.deleted =false
, you should compare RUs with and without a composite index on /partitionKey/?
and /deleted/?
(https://learn.microsoft.com/azure/cosmos-db/how-to-manage-indexing-policy#composite-indexing-policy-examples). In some cases, you will get lower RUs with the composite index than with the default of /*
which only indexes them individually, potentially close to ~5 RUsUpvotes: 3