Re: Strange (?) Index behavior?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Allen Landsidel <alandsidel(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Strange (?) Index behavior?
Date: 2004-11-05 17:51:59
Message-ID: 20041105175159.GB8855@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Fri, Nov 05, 2004 at 09:39:16 -0500,
Allen Landsidel <alandsidel(at)gmail(dot)com> wrote:
>
> For some reason it's a requirement that partial wildcard searches are
> done on this field, such as "SELECT ... WHERE field LIKE 'A%'"
>
> I thought an interesting way to do this would be to simply create
> partial indexes for each letter on that field, and it works when the
> query matches the WHERE clause in the index exactly like above. The
> problem is thus:

That may not help much except for prefixes that have a below average
number of occurences. If you are going to be select 1/26 of the records,
you are probably going to do about as well with a sequential scan as an
index scan.

Just having a normal index on the column will work if the database locale
is C. In 7.4 you can create an index usable by LIKE even in the database
locale isn't C, but I don't remember the exact syntax. You will be better
off having just one index rather than 26 partial indexes.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Allen Landsidel 2004-11-05 17:56:47 Re: Strange (?) Index behavior?
Previous Message Michael Fuhr 2004-11-05 17:45:34 Re: Checking = with timestamp field is slow