Functional Index Question

From: "James B(dot) Byrne" <byrnejb(at)harte-lyne(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Functional Index Question
Date: 2008-03-12 15:46:12
Message-ID: 53676.216.185.71.22.1205336772.squirrel@webmail.harte-lyne.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)Harte-Lyne(dot)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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dave Page 2008-03-12 15:53:57 PostgreSQL user documentation wiki open for business
Previous Message Tim Child 2008-03-12 15:19:48 Re: ERROR: text search configuration "pg_catalog.english" does not exist