Re: Regex Query Index question
От | David Johnston |
---|---|
Тема | Re: Regex Query Index question |
Дата | |
Msg-id | 1EBCDA78-0C15-4C12-8B99-232CEDF23CAC@yahoo.com обсуждение исходный текст |
Ответ на | Regex Query Index question (Naoko Reeves <naokoreeves@gmail.com>) |
Ответы |
Re: Regex Query Index question
|
Список | pgsql-general |
Hello,I have query phone number in database as follows:[123) 456-7890
(123) 456-7890
When I query like this:
SELECT * FROM phone
WHERE phone_number ~ ('^\[123' || '[-\s\)]{0,2}' || '456' || '[-\s\)]{0,2}' || '7890')
it use Index but if I query like this (notice first character is open parenthesis instead of open square blacket ) :
SELECT phn_fk_key FROM phn WHERE
phn_fk_table = 14
AND llx_decrypt(phn_phone_enc) ~ ('^\(123' || '[-\s\)]{0,2}' || '456' || '[-\s\)]{0,2}' || '7890')
It doesn't use Index....
Particularly with RegEx you want to tell people what you are trying to do and not just give the expressions themselves.co-worker suggested me to use chr(40) instead so I tried this:
SELECT phn_fk_key FROM phn WHERE
phn_fk_table = 14
AND llx_decrypt(phn_phone_enc) ~ ('^\' || chr(40) || '123' || '[-\s\)]{0,2}' || '456' || '[-\s\)]{0,2}' || '7890')
No success...
Also { and period doesn't seems to use index either.... but } ) [ ] $ # works.Could you guide me to right direction for me please?
В списке pgsql-general по дате отправления:
Предыдущее
От: Rich ShepardДата:
Сообщение: Re: suggestions for archive_command to a remote standby