Re: case-insensitive Index

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: kmh496 <kmh496(at)kornet(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: case-insensitive Index
Date: 2006-07-26 14:49:38
Message-ID: 1791.1153925378@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

kmh496 <kmh496(at)kornet(dot)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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Andrew Hammond 2006-07-26 17:17:24 Re: Installation "baby" steps (next steps)?
Previous Message Michael Swierczek 2006-07-26 13:27:41 Re: Novice! How to run pg_dump from within Java?