Re: Case insensitive selects?

From: "Mitch Vincent" <mitch(at)venux(dot)net>
To: "David Wheeler" <david(at)creationengines(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Case insensitive selects?
Date: 2001-02-16 19:39:00
Message-ID: 002701c09850$1d3370d0$0200000a@windows
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Hmmm...I'd hate to have two indexes on every field I query like this, one
> case-senstive, one case-insensitve (like the one you create here). Is
> there a configuration option or something that will tell pgsql to do
> case-insensitive comparisons (kinda like MS SQL Server has)? That could
> save us on indexing overhead, since we want all of our WHERE comparisons
> to be case-insensitive, anyway.

If you want all of them to be case insensitive then make the upper ( or
lower() ) index and don't make any case sensitive queries! :-)

Make sure all your queries use upper() or lower() around the field and value
you're comparing and you're golden.. Unless I've misunderstood you, I don't
see the problem..

SELECT * FROM whatever WHERE lower(myfield) = lower('myvalue'); -- and make
your index on lower(myfield)... Viola!

-Mitch

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Simon Attwell 2001-02-16 19:40:06 Locking
Previous Message Tom Lane 2001-02-16 19:30:32 Re: order of clauses