Re: Trigram (pg_trgm) GIN index not used

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Ivan Voras <ivoras(at)freebsd(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: Trigram (pg_trgm) GIN index not used
Date: 2013-02-21 16:07:25
Message-ID: CAHyXU0xmLCTQpYkD8uZhw2=T8JUqcfucO2Q+9B4bGiJZr+hLAg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Feb 21, 2013 at 9:57 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Ivan Voras <ivoras(at)freebsd(dot)org> writes:
>> I have a table with the following structure:
>> ...
>> raw_data | citext | not null
>> ...
>> "documents_raw_data_trgm" gin (raw_data gin_trgm_ops)
>
>> I'd like to use pg_trgm for matching substrings case-insensitively, but
>> it doesn't seem to use the index:
>
> You're outsmarting yourself by using citext as the column datatype.
> That causes "ilike" to be interpreted as a citext-specific operator,
> which is not a member of the gin_trgm_ops operator class, so it doesn't
> match this index.
>
> I wonder whether we really need that citext-specific operator at all
> ... but in the meantime, if you need the column to be citext for some
> other reason, I'd suggest making a gin index on raw_data::text and
> then writing the query as raw_data::text ilike '%zagreb%'.

hm, one more data point that citext implementation didn't succeed in
terms of abstracting you from case sensitivity issues.

merlin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2013-02-21 16:27:53 Re: Trigram (pg_trgm) GIN index not used
Previous Message Tom Lane 2013-02-21 15:57:45 Re: Trigram (pg_trgm) GIN index not used