best way to manage indexes

From: Jamie Kahgee <jamie(dot)kahgee(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: best way to manage indexes
Date: 2009-12-23 22:10:21
Message-ID: da6bca20912231410g731b3555h53703eacc2e15588@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2009-12-24 02:05:23 Re: best way to manage indexes
Previous Message Patrick M. Rutkowski 2009-12-23 21:58:47 Re: WARNING: nonstandard use of escape in a string literal