From: | "Erik Rijkers" <er(at)xs4all(dot)nl> |
---|---|
To: | "Alexander Korotkov" <aekorotkov(at)gmail(dot)com> |
Cc: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: trgm regex index peculiarity |
Date: | 2013-06-21 13:39:50 |
Message-ID: | 657ec9f92df7fc15c8a586b1fe355c46.squirrel@webmail.xs4all.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, June 21, 2013 15:11, Alexander Korotkov wrote:
> On Fri, Jun 21, 2013 at 2:40 PM, Erik Rijkers <er(at)xs4all(dot)nl> wrote:
>
>> On Fri, June 21, 2013 05:25, Tom Lane wrote:
>> > "Erik Rijkers" <er(at)xs4all(dot)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.
Erik Rijkers
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2013-06-21 13:47:03 | Re: Support for REINDEX CONCURRENTLY |
Previous Message | Robert Haas | 2013-06-21 13:28:37 | Re: [PATCH] pgbench --throttle (submission 7 - with lag measurement) |