![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Why doesn't it use an index on the "like" operator when it doesn't contain a wildcard in the beginning of the pattern? |
#3
| |||
| |||
|
|
Why doesn't it use an index on the "like" operator when it doesn't contain a wildcard in the beginning of the pattern? |
#4
| |||
| |||
|
|
Jesper, Why doesn't it use an index on the "like" operator when it doesn't contain a wildcard in the beginning of the pattern? How many rows are there in the table? What happens if you force an index scan on the 2nd query? Is this ASCII text or UNICODE text? Normally LIKE 'xxx%' does use an index if it's useful, so there is something else going on here. |
#5
| |||
| |||
|
|
Jesper Krogh <jesper (AT) krogh (DOT) cc> writes: Why doesn't it use an index on the "like" operator when it doesn't contain a wildcard in the beginning of the pattern? Probably because your locale isn't C --- locale-specific sort ordering usually isn't compatible with the needs of LIKE, so we can only make that optimization in C locale. You can either re-initdb in C locale, or (if you're using 7.4) create a specialized index with non-locale-dependent comparison operators. See the manual concerning specialized index operator classes. |
![]() |
| Thread Tools | |
| Display Modes | |
| |