How to make LIKE to use index in "abc%" query?

From: "Dmitry Koterov" <dmitry(at)koterov(dot)ru>
To: "Postgres General" <pgsql-general(at)postgresql(dot)org>
Subject: How to make LIKE to use index in "abc%" query?
Date: 2007-10-08 16:41:54
Message-ID: d7df81620710080941l27c46c22y397061975bb15718@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello.

I run

explain analyze
SELECT id FROM "table" WHERE name LIKE 'dt%';

having a btree index on "name" column. But unfortunately it uses seqscan
instead of index scan, it's too slow.

I had read some mailing archives about that problem, but have not found a
solution. How to fix this LIKE behaviour withour re-creation af the whole
database? Is it possible?

I use windows-1251 locale, not C locale.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dimitri Fontaine 2007-10-08 16:52:16 Re: How to make LIKE to use index in "abc%" query?
Previous Message Ben 2007-10-08 16:29:25 Re: Re : Very asynchrnous replication system