Re: [GENERAL] Functional Index Question

2008-03-13 Thread James B. Byrne
On Wed, March 12, 2008 17:02, hubert depesz lubaczewski wrote: correct way: select lower(trim(both ' ' from(regexp_replace(' depeSz hub ', E'\\s+', ' ', 'g' ; now. i would suggest *not* to use this as base for index. make a wrapper function instead: create function cleaned(text)

Re: [GENERAL] Functional Index Question

2008-03-13 Thread hubert depesz lubaczewski
On Thu, Mar 13, 2008 at 09:04:28AM -0400, James B. Byrne wrote: To return to my first question. Is doing this sort of thing considered good a practice? for me - yes. keeping it in database is the best and safest option. but you might get issues with orms. where they really belong. However,

Re: [GENERAL] Functional Index Question

2008-03-13 Thread Craig Ringer
James B. Byrne wrote: I am considering moving theses sorts of purification routines into the DBMS because I feel that is where they really belong. However, the prevailing sentiment of the community surrounding Rails seems to hold otherwise so I wonder if this is really the right thing to do.

[GENERAL] Functional Index Question

2008-03-12 Thread James B. Byrne
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 ' '

Re: [GENERAL] Functional Index Question

2008-03-12 Thread hubert depesz lubaczewski
On Wed, Mar 12, 2008 at 11:46:12AM -0400, James B. Byrne wrote: 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