Re: efficiency of wildcards at both ends

From: Alan Hodgson <ahodgson(at)simkin(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: efficiency of wildcards at both ends
Date: 2012-06-20 17:39:11
Message-ID: 2772502.y0rLb9S7jb@skynet.simkin.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sam Z J 2012-06-20 17:40:31 Re: efficiency of wildcards at both ends
Previous Message Edson Richter 2012-06-20 17:37:51 Re: efficiency of wildcards at both ends