Re: case-insensitive Index - Mailing list pgsql-novice

From Tom Lane
Subject Re: case-insensitive Index
Date
Msg-id 1791.1153925378@sss.pgh.pa.us
Whole thread Raw
In response to Re: case-insensitive Index  (kmh496 <kmh496@kornet.net>)
List pgsql-novice
kmh496 <kmh496@kornet.net> writes:
> I tried declaring a varchar_pattern_ops and text_varchar_ops on a
> character varying (60) column but it still does a sequential scan on the
> column.

That's because the index doesn't match the query:

> mod=# create index english_english_word_idx on
> english_english(UPPER(word) text_pattern_ops)

> mod=# explain select word from english_english where word like 'here';

You'd need
    select word from english_english where upper(word) like upper('here');
to use that index (and also to get the right answer, if your goal is
case-insensitive matching).

            regards, tom lane

pgsql-novice by date:

Previous
From: "Michael Swierczek"
Date:
Subject: Re: Novice! How to run pg_dump from within Java?
Next
From: "Andrew Hammond"
Date:
Subject: Re: Installation "baby" steps (next steps)?