Re: Question about trigram GIST index - Mailing list pgsql-performance

From Tom Lane
Subject Re: Question about trigram GIST index
Date
Msg-id 18097.1418923132@sss.pgh.pa.us
Whole thread Raw
In response to Question about trigram GIST index  (Robert DiFalco <robert.difalco@gmail.com>)
Responses Re: Question about trigram GIST index
List pgsql-performance
Robert DiFalco <robert.difalco@gmail.com> writes:
> So, for my use case I simply need to search for a case insensitive
> substring. It need not be super exact. It seems like there are two ways I
> can do this:

> CREATE INDEX idx_users_name ON users USING GIST(lower(name) gist_trgm_ops);
> SELECT * FROM users WHERE lower(name) LIKE '%john%';

> Or I can do it like this:

> CREATE INDEX idx_users_name ON users USING GIST(name gist_trgm_ops);
> SELECT * FROM users WHERE name % 'john';

Hm, I don't see anything in the pg_trgm docs suggesting that % is
case-insensitive.  But in any case, I'd go with the former as being
more understandable to someone who knows standard SQL.

            regards, tom lane


pgsql-performance by date:

Previous
From: Robert DiFalco
Date:
Subject: Question about trigram GIST index
Next
From: Alessandro Ipe
Date:
Subject: Re: Excessive memory used for INSERT