Number of occurrence of characters?

Поиск
Список
Период
Сортировка
От Ivan Voras
Тема Number of occurrence of characters?
Дата
Msg-id gmepnh$7da$1@ger.gmane.org
обсуждение исходный текст
Ответы Re: Number of occurrence of characters?  (hubert depesz lubaczewski <depesz@depesz.com>)
Re: Number of occurrence of characters?  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Список pgsql-performance
Hi,

I have a need to fairly often select data where the number of
occurrences of a character in the field is "x". Semantically, it's
literally "SELECT something FROM table WHERE numch('/', field)=$x".

The problem is how to do it efficiently. I see there isn't a built-in
function that counts character occurrences so I'd have to write it
myself. An additional constraint is that it must be implemented with
built-in capabilities, i.e. SQL and plpsql languages. I can do it the
brute force way, looping over the string and processing one by one
character with substring(), but is there a faster way?

Whatever the function is, I intend to create an index on it.


Вложения

В списке pgsql-performance по дате отправления:

Предыдущее
От: Matt Burke
Дата:
Сообщение: Re: suggestions for postgresql setup on Dell 2950 , PERC6i controller
Следующее
От: Gregory Stark
Дата:
Сообщение: Re: suggestions for postgresql setup on Dell 2950 , PERC6i controller