Re: Behavior of a pg_trgm index for 2 (or < 3) character LIKE queries

From: Sawada Masahiko <sawada(dot)mshk(at)gmail(dot)com>
To: Amit Langote <amitlangote09(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Behavior of a pg_trgm index for 2 (or < 3) character LIKE queries
Date: 2013-05-30 16:49:46
Message-ID: CAD21AoBewYm2Xm6S6wrsdzSiY93ygJw4V+yunVgHrxODmqpQYg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2013/5/31 Amit Langote <amitlangote09(at)gmail(dot)com>
>
> On Thu, May 30, 2013 at 11:47 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> > On Wed, May 29, 2013 at 10:51 PM, Amit Langote <amitlangote09(at)gmail(dot)com> wrote:
> >> So, it appears, for search strings consisting of 2 (or < 3)
> >> characters, trigrams can not be utilized. No?
> >
> > I think that's right. "trigram" means a sequence of three characters,
> > and what's stored in the indexes are three-character sequences from
> > the original text.
> >
>
> Was there any improvement to pg_trgm in recent past that could make it
> better for partial matching (the case in question I suppose) or is
> partial-matching a different thing altogether?
>

Hi Amit,

following emails are discussed about partial match of pg_trgm. I hope
will this help.
<http://www.postgresql.org/message-id/CAHGQGwFJshvV2nGME19wdTW9teFw_w7h2ns4E+YYsjkB9WdWDQ@mail.gmail.com>
as you may know, if search string contains multibyte characters
trigram key is converted to CRC of 4 byte and it is used as key.
(but only use upper 3 byte from CRC)
so we can do partial matching if KEEPONLYALNUM is enabled.

Regards,

--------
Masahiko Sawada

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2013-05-30 16:52:02 9.3: Empty arrays returned by array_remove()
Previous Message Robert Haas 2013-05-30 16:47:07 Re: Behavior of a pg_trgm index for 2 (or < 3) character LIKE queries