Re: trgm regex index peculiarity

Поиск
Список
Период
Сортировка
От Alexander Korotkov
Тема Re: trgm regex index peculiarity
Дата
Msg-id CAPpHfduREkHNcsrs0cXGrFRj=LQ8-N7DOrJYo+3BNFcZaWcLLw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: trgm regex index peculiarity  ("Erik Rijkers" <er@xs4all.nl>)
Ответы Re: trgm regex index peculiarity  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Fri, Jun 21, 2013 at 5:39 PM, Erik Rijkers <er@xs4all.nl> wrote:
On Fri, June 21, 2013 15:11, Alexander Korotkov wrote:
> On Fri, Jun 21, 2013 at 2:40 PM, Erik Rijkers <er@xs4all.nl> wrote:
>
>> On Fri, June 21, 2013 05:25, Tom Lane wrote:
>> > "Erik Rijkers" <er@xs4all.nl> writes:
>> >> In a 112 MB test table (containing random generated text) with a trgm
>> index (gin_trgm_ops), I consistently get these
>> >> timings:
>> >> select txt from azjunk6 where txt ~ '^abcd';
>> >>    130 ms
>> >> select txt from azjunk6
>> >> where txt ~ 'abcd' and substr(txt,1,4) = 'abcd';
>> >>    3 ms
>> >
>
> Regex '^abcd' will be expanded into trigrams '__a', '_ab', 'abc' and 'bcd'.
> However trigrams '__a' is much more frequent than '_ab' which in turn is
> much more frequent than 'abc' and 'bcd'. Ommiting of ^ leads to ommiting of
> '__a' and '_ab' and that gives so significant speedup.

> [trgm_regex_optimize.1.patch ]

Yes, that fixes the problem, thanks.

Revised version of patch with necessary comments.

------
With best regards,
Alexander Korotkov.
Вложения

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

Предыдущее
От: Jan Kara
Дата:
Сообщение: Re: [Lsf-pc] Linux kernel impact on PostgreSQL performance
Следующее
От: Hannu Krosing
Дата:
Сообщение: Re: [Lsf-pc] Linux kernel impact on PostgreSQL performance