I have a Cosmos DB collection with 4 million documents (~5GB). The following query reports a charge of 2.79 RUs:
SELECT * FROM c WHERE c.type='type1' and STRINGEQUALS(c.name,'abc',false)
But the same query with case-insensitive search (by replacing false
by true
) costs 1228 RUs.
Is there an explanation for why the case-insensitive query is more than 470 times more expensive than the case-sensitive query? I'm surprised by this because the documentation states
The RU charge for StartsWith and StringEquals is slightly higher with the case-insensitive option than without it.
Details:
- Both queries return 0 results.
- The partition key is
type
. - The logical partition
type1
contains 2 million documents. - The
name
property has a different value for almost all 2 million documents. - The default indexing strategy is used (
"path": "/*"
)
c.type = 'type1'
restricts the number of possible results to a small number or the cardinality ofc.name
is much smaller in your collection. - Mo B.c.type
expression so the query ran over my entire collection filtering on a MD5 hash. Upon trying the same with a new database with 12 million documents the performance gets even worse than your results with 569604 RU. I'm quite surprised about that outcome considering my 100k collection barely showed a difference. Adding anorder by c.md5
to force an index scan lowers it to 7700 RU - 404