Re: indexing and LIKE

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Patrik Kudo <kudo(at)partitur(dot)se>
Cc: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>, pgsql-sql(at)postgresql(dot)org
Subject: Re: indexing and LIKE
Date: 2001-10-12 17:32:15
Message-ID: 27330.1002907935@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Patrik Kudo <kudo(at)partitur(dot)se> writes:
> Thanks for your respons, but I'm afraid it didn't help. I've succeeded
> with indexing my table using functional indices, but the problem is that
> the index I create won't work with my query.

Works for me:

test71=# create table person (last_name text);
CREATE
test71=# create index person_lower_lname_idx on person (lower(last_name));
CREATE
test71=# explain select * from person where lower(last_name) like 'kud%';
NOTICE: QUERY PLAN:

Index Scan using person_lower_lname_idx on person (cost=0.00..8.16 rows=10 width=12)

EXPLAIN

The difference is probably a locale problem: if you aren't in C locale
then the index LIKE optimization is disabled because it doesn't work
reliably. See the list archives for more info.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2001-10-12 18:17:52 Re: indexing and LIKE
Previous Message leo 2001-10-12 16:05:45 problem w/plpgsql proc