BUG: LIKE with ESCAPE May Result in Different Query Access Plan (262340)
The information in this article applies to:
- Microsoft SQL Server 7.0
- Microsoft SQL Server 2000 (all editions)
This article was previously published under Q262340
BUG #: 57398 (SQLBUG_70)
SYMPTOMS
An ESCAPE character in a LIKE expression allows you to search for a wildcard character in a character string. To denote this special use, you place the ESCAPE character in front of the wildcard character.
The problem is that the optimizer chooses to perform an index SCAN instead of a SEEK. Consequentially, query performance may deteriorate with large tables.
WORKAROUND
You can decrease the performance impact by evaluating your indexing architecture. For instance, if you have alternate unique row identifiers, you can use them to get your data. Or, you can add more columns (with indexes) to the query predicate to persuade the optimizer to use a SEEK against those indexes. Then, you use a FILTER on the result set, which uses the ESCAPE clause of the LIKE.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Major | Last Reviewed: | 10/29/2003 |
---|
Keywords: | kbBug kbpending KB262340 |
---|
|