Mixed case text searches - Mailing list pgsql-novice

From Chris Campbell
Subject Mixed case text searches
Date
Msg-id 453A24085F801842AEA8D0B6B269065D2F8BA64CE3@HDMC.cds.local
Whole thread Raw
Responses Re: Mixed case text searches  (Thom Brown <thombrown@gmail.com>)
List pgsql-novice

Hi list people.  Okay I’ve read the documentation.  Now it’s time to talk to people that actually do this for a living.  Mixed case searches, what is the best practice?

I’m searching for an account name:  Acme Rockets Inc.

 

strSearchString = ‘acme%’

Select * From Accounts Where AccountName = strSearchString

This will of course fail because the case doesn’t match.  So what is the best practice for performance?

 

I could use the Lower() function:

strSearchString = lower(‘acme%’)

Select * From Accounts Where lower(AccountName) = strSearchString

 

Or I could use the ilike operator

strSearchString = ‘acme%

Select * From Accounts Where AccountName ilike  strSearchString

 

It’s also been suggested that I keep a companion column that mirrors the account name column which is forced to lower case.  This seems, well a bit desperate to me.

 

So, from a performance standpoint, what are people doing and why?

 

Many thanks for your replies.

 

Chris Campbell

 

pgsql-novice by date:

Previous
From: "Jean-Yves F. Barbier"
Date:
Subject: Re: (not so?) silly question
Next
From: Thom Brown
Date:
Subject: Re: Mixed case text searches