For CosmosDB case-insensitive queries: use duplicate uppercased field or StringEquals?

Viewed 79

Suppose you are trying to see whether a username is available to take in your DB, and while usernames display with the original casing, for checking availability you want the check to be case-insensitive.

The old way of doing this would be to have an extra field in your schema that is uppercasedUsername and look up based on that, relying on the index to find it quickly.

I recently saw that in June 2020 they improved the performance of some system functions like StringEquals that include case-insensitive lookup, but it's unclear to me whether these rely on an index or they just did some perf improvement. Is the performance of StringEquals comparable to lookups on a duplicated uppercased field at scale?

1 Answers

Yes these rely upon the index. The cost is just slightly higher than if you were going to duplicate the data and do it yourself.

Related