Re: efficiency of wildcards at both ends - Mailing list pgsql-general

From Alan Hodgson
Subject Re: efficiency of wildcards at both ends
Date
Msg-id 2772502.y0rLb9S7jb@skynet.simkin.ca
Whole thread Raw
In response to efficiency of wildcards at both ends  (Sam Z J <sammyjiang721@gmail.com>)
Responses Re: efficiency of wildcards at both ends  (Sam Z J <sammyjiang721@gmail.com>)
Re: efficiency of wildcards at both ends  (Thomas Kellerer <spam_eater@gmx.net>)
List pgsql-general
On Wednesday, June 20, 2012 01:10:03 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?
>

Indexing helps not at all. If the search string starts with a wildcard you
will always get a sequential scan of the whole table.

Look at the full text search documentation for a better approach.

pgsql-general by date:

Previous
From: Edson Richter
Date:
Subject: Re: efficiency of wildcards at both ends
Next
From: Sam Z J
Date:
Subject: Re: efficiency of wildcards at both ends