|
With the index, the optimizer chooses to evaluate the problematic
[CASE...END] = 1346100 predicate before it evaluates the
LENGTH(TRIM(CPCSID))=10 predicate. It does this because it splits the data
access into an index scan and a table probe. For performance, it pushes as
much selection into the index scan as it can. But because char fields are
stored in the index without trailing blanks, the optimizer has to wait to
evaluate the LENGTH of a char field until has the "real" data from the
table.
On the other hand, the TRANSLATE predicate can be evaluated in the index
scan node. There's no need to defer its evaluation until later. This
allows it to be evaluated (to FALSE) before the problematic [CASE...END] =
1346100 predicate. This gives you the behavior that you are seeing (and
expecting.)
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.