| From: | Andy Colson <andy(at)squeakycode(dot)net> |
|---|---|
| To: | Sam Z J <sammyjiang721(at)gmail(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: efficiency of wildcards at both ends |
| Date: | 2012-06-20 17:22:41 |
| Message-ID: | 4FE206E1.6010702@squeakycode.net |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On 6/20/2012 12:10 PM, Sam Z J wrote:
> Hi all
>
> I'm curious how is wildcards at both ends implemented, e.g. LIKE '%str%'
> How efficient is it if that's the only search criteria against a large
> table? how much does indexing the column help and roughly how much more
> space is needed for the index?
>
> if the answers are too long, please point me to the relavant text =D
>
> thanks
>
> --
> Zhongshi (Sam) Jiang
> sammyjiang721(at)gmail(dot)com <mailto:sammyjiang721(at)gmail(dot)com>
An index will not be used for that kind of search. PG will scan the
entire table to find matches. PG can only use an index if you have a
search LIKE 'str%'
There are options like full text search, and pg_trgm that you might be
able to use.
-Andy
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Edson Richter | 2012-06-20 17:28:20 | Re: efficiency of wildcards at both ends |
| Previous Message | Lonni J Friedman | 2012-06-20 17:20:58 | Re: efficiency of wildcards at both ends |