Functional Index Question - Mailing list pgsql-general

From James B. Byrne
Subject Functional Index Question
Date
Msg-id 53676.216.185.71.22.1205336772.squirrel@webmail.harte-lyne.ca
Whole thread Raw
Responses Re: Functional Index Question  (hubert depesz lubaczewski <depesz@depesz.com>)
List pgsql-general
I am considering the utility value of creating a functional index on a name
field.  To minimize the number of invalid searches caused by spacing errors
and mis-matched lettercase I am contemplating doing something like this:

CREATE UNIQUE INDEX idxUF_table_column ON table
  (lower(trim(both ' ' from(regexp_replace(<column>, /( ){2,}/g," " )))))

What I intend this to do is to squeeze out excess whitespace, strip off
leading and trailing blanks, and then force the whole thing to lowercase.

Is this idea worth pursuing and, if it is, is my regexp correct for the
purpose intended?

Not a regexp guy.

--
***          E-Mail is NOT a SECURE channel          ***
James B. Byrne                mailto:ByrneJB@Harte-Lyne.ca
Harte & Lyne Limited          http://www.harte-lyne.ca
9 Brockley Drive              vox: +1 905 561 1241
Hamilton, Ontario             fax: +1 905 561 0757
Canada  L8E 3C3


pgsql-general by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: PostgreSQL won't start
Next
From: "Lee Hachadoorian"
Date:
Subject: Re: PostgreSQL won't start