Re: query with pg_trgm sometimes very slow

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Claudio Freire <klaussfreire(at)gmail(dot)com>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Volker Böhm <volker(at)vboehm(dot)de>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: query with pg_trgm sometimes very slow
Date: 2015-09-08 19:15:43
Message-ID: CAHyXU0w2iUAA-_dreEK+5PE_0zdNFRHivtn_OHQf20fGkVxYDw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Thu, Sep 3, 2015 at 6:19 PM, Claudio Freire <klaussfreire(at)gmail(dot)com> wrote:
> On Wed, Sep 2, 2015 at 4:29 PM, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:
>> On Wed, Sep 2, 2015 at 7:00 AM, Volker Böhm <volker(at)vboehm(dot)de> wrote:
>>>
>>>
>>>
>>> CREATE INDEX trgm_adresse ON adressen.adresse USING gist
>>> (normalize_string((btrim((((((((normalize_string((((COALESCE((vorname)::text,
>>> ''::text) || ' '::text) || (name1)::text))::character varying,
>>> (-1)))::text || ' '::text) || (normalize_string((COALESCE((strasse)::text,
>>> ''::text))::character varying, (-2)))::text) || ' '::text) || (plz)::text)
>>> || ' '::text) || (normalize_string((COALESCE((ort)::text,
>>> ''::text))::character varying, (-3)))::text)))::character varying)
>>> gist_trgm_ops);
>>
>>
>>
>> You might have better luck with gin_trgm_ops than gist_trgm_ops. Have you
>> tried that?
>
>
> I just had the exact same problem, and indeed gin fares much better.

Also, with 9.5 we will see much better worst case performance from gin
via Jeff's patch:
http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=97f3014647a5bd570032abd2b809d3233003f13f

(I had to previously abandon pg_tgrm for a previous project and go
with solr; had this patch been in place that would not have happened)

merlin

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tomas Vondra 2015-09-08 21:21:21 Re: query with pg_trgm sometimes very slow
Previous Message Julien Rouhaud 2015-09-08 18:26:17 Re: Allow a per-tablespace effective_io_concurrency setting