From: | Robert DiFalco <robert(dot)difalco(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Question about trigram GIST index |
Date: | 2014-12-18 17:32:39 |
Message-ID: | CAAXGW-yy_5NjC1b8qJLkGRf-FskSb0aEDrRWdFqw1yq2mxN3EQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
I know! I was surprised that % 'John' or % 'JOHN' or even % 'jOhn' all
returned the same result.
Besides readability would there be any technical differences between a GIST
index that is lower or not and using LIKE vs. %?
Thanks!
On Thu, Dec 18, 2014 at 9:18 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Robert DiFalco <robert(dot)difalco(at)gmail(dot)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
>
From | Date | Subject | |
---|---|---|---|
Next Message | Giuseppe Broccolo | 2014-12-18 18:00:00 | Re: Question about trigram GIST index |
Previous Message | Alessandro Ipe | 2014-12-18 17:31:42 | Re: Excessive memory used for INSERT |