Re: Case insensitive selects? - Mailing list pgsql-general

From Mitch Vincent
Subject Re: Case insensitive selects?
Date
Msg-id 002701c09850$1d3370d0$0200000a@windows
Whole thread Raw
In response to Re: Case insensitive selects?  (David Wheeler <david@creationengines.com>)
List 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


pgsql-general by date:

Previous
From: "Janardhan Sridhar"
Date:
Subject: Easy creation of database driven web sites.
Next
From: Angelo DiSanto
Date:
Subject: Question