[FEATURE REQ] Change to how case sensitivity is added to functions in queries #29543
Closed
2 tasks done
Labels
azure-spring-cosmos
Spring cosmos related issues.
Client
This issue points to a problem in the data-plane of the library.
Cosmos
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
needs-team-attention
Workflow: This issue needs attention from Azure service team or SDK team
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Is your feature request related to a problem? Please describe.
There is a performance issue when using Case Insensitive querying with CosmosDB and functions. Currently the code is wrapping all of those calls with UPPER() around the parameters. UPPER() forces a table scan without indexes per https://docs.microsoft.com/en-us/azure/cosmos-db/sql/sql-query-upper. This is easy to see the performance implications with some simple querying:
It becomes very clear when comparing this scenario that there is room for improvement. Those numbers are from actual queries in an actual database.
Describe the solution you'd like
The example above alludes to my suggestion for a solution also. This method -
azure-sdk-for-java/sdk/cosmos/azure-spring-data-cosmos/src/main/java/com/azure/spring/data/cosmos/core/generator/AbstractQueryGenerator.java
Line 100 in 53aa670
Then it would benefit from the index scan performance improvements.
Additional context
That call relies on a check of CriteriaType.isFunction(CriteriaType type). Currently that check would also return true for IS_NULL and IS_NOT_NULL. Those functions do not support the third parameter per https://docs.microsoft.com/en-us/azure/cosmos-db/sql/sql-query-is-null and would need some additional logic to prevent accidental usage. Perhaps a check of some kind around CriteraType.isUnary(CriteriaType type) returning false or something along those lines.
Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
The text was updated successfully, but these errors were encountered: