From: Stephan Szabo <sszabo@megazone23.bigpanda.com>
To: Patrik Kudo <kudo@partitur.se>
Cc: Ross J. Reedstrom <reedstrm@rice.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: indexing and LIKE
Date: Fri, 12 Oct 2001 11:17:52 -0700 (PDT)
Message-ID: <Pine.BSF.4.21.0110121115460.97475-100000@megazone23.bigpanda.com> (raw)
In-Reply-To: <20011012100747.I99068-100000@tb303.partitur.se>
On Fri, 12 Oct 2001, Patrik Kudo wrote:
> kudo=# select version();
> version
> --------------------------------------------------------------
> PostgreSQL 7.1.3 on i386--freebsd4.3, compiled by GCC 2.95.3
> (1 row)
>
> kudo=# create index person_lower_lname_idx on person (lower(last_name));
> CREATE
> kudo=# vacuum analyze person;
> VACUUM
> kudo=# explain select userid, first_name, last_name from person where lower(last_name) like 'kud%';
> NOTICE: QUERY PLAN:
>
> Seq Scan on person (cost=0.00..217.44 rows=70 width=36)
>
> EXPLAIN
> kudo=# explain select userid, first_name, last_name from person where lower(last_name) = 'kudo';
> NOTICE: QUERY PLAN:
>
> Index Scan using person_lower_lname_idx on person (cost=0.00..57.82 rows=70 width=36)
>
> As you can see, the functional index is working fine when using the
> "normal" = operator. However, it is not used when using the "like"
> operator, which I need. I understand that a pattern-matched query probably
> can't be made as effective as a query with =, but I think it, at least
> theoretically, should be possible to use a btree-index to find matches in
> the first query above.
>
> Am I totaly wrong here? What is possible/impossible with Postgres?
Are you running with locale support turned on, and if so what locale?
IIRC, if it's not C locale Postgres won't use the index.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: sszabo@megazone23.bigpanda.com, kudo@partitur.se, reedstrm@rice.edu
Subject: Re: indexing and LIKE
In-Reply-To: <Pine.BSF.4.21.0110121115460.97475-100000@megazone23.bigpanda.com>
References: <20011012100747.I99068-100000@tb303.partitur.se> <Pine.BSF.4.21.0110121115460.97475-100000@megazone23.bigpanda.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox