Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This advisor message is returned when a query uses case-insensitive string comparison functions. The message clarifies the reason and provides guidance to improve query performance.
Properties
| Value | |
|---|---|
| RuleID | QA1003 |
| Title | CaseInsensitiveStartsWithOrStringEquals |
| Category | Performance |
Cause
The query uses case-insensitive STARTSWITH or StringEquals.
Rule Description
Case-insensitive string searches can be costly. For example, case-sensitive STARTSWITH uses a precise index scan, but case-insensitive STARTSWITH uses an [expanded index scan](Overview of Indexing).
Recommendation
Define and index a computed property that converts the string to lowercase (or upper case) and use case-sensitive comparison against the computed property.
Example
Original query:
SELECT *
FROM c
WHERE StringEquals(c.name, "abc", true)
Create a compute property on c.name
{
"computedProperties": [
{
"name": "cp_lowerName",
"query": "SELECT VALUE LOWER(c.name) FROM c"
}
]
}
Index cp_lowerName and the use the following updated query:
SELECT *
FROM c
WHERE StringEquals(c.name, "abc", false)