best way to manage indexes - Mailing list pgsql-general

From Jamie Kahgee
Subject best way to manage indexes
Date
Msg-id da6bca20912231410g731b3555h53703eacc2e15588@mail.gmail.com
Whole thread Raw
Responses Re: best way to manage indexes  (Scott Marlowe <scott.marlowe@gmail.com>)
Re: best way to manage indexes  (Craig Ringer <craig@postnewspapers.com.au>)
List pgsql-general
what would be considered "best practice" for my situation?

I have a table member, with column name that I want to put an index on, because it is searched quiet frequently. When I create my sql search string, the name will consist only of alpha-numeric characters and be compared against lowercase matches.

SELECT *
  FROM member
 WHERE lower(regexp_replace(member_name, '[^[:alnum:]]', '', 'g')) ~* 'search_string'
    OR lower(metaphone(name, 4)) = lower(metaphone('search_string', 4));

is it better to create an index that matches my search?
create index member_name_idx on member (lower(regexp_replace(name, '[^[:alnum:]]', '', 'g')));
What if we decide we want to allow more characters in the search later - just have to remember to update the index?

do I need two indexes?  one for both search parameters (regexp & metaphone)?

perhaps there is a solution that I haven't thought of.  any input would be appreciated!

Thanks,
Jamie K.

pgsql-general by date:

Previous
From: "Patrick M. Rutkowski"
Date:
Subject: Re: WARNING: nonstandard use of escape in a string literal
Next
From: Scott Marlowe
Date:
Subject: Re: best way to manage indexes