Re: Lexicographic index ?

From: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org, arnaud(dot)mlist1(at)free(dot)fr
Subject: Re: Lexicographic index ?
Date: 2002-05-16 14:26:06
Message-ID: 20020516142606.35386.qmail@web20809.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

An alternative, which may work well for you: create an
index on a substring (say, the first five or six
characters) of each word, and match against that. To
index on a substring, you will need to create a
function, something like:

CREATE FUNCTION word_substring(text) RETURNS text AS'
SELECT substr($1, 1, 5);
'LANGUAGE SQL
WITH (iscachable);

CREATE INDEX word_substring_index ON word_table
(word_substring(word));

--- Marin Dimitrov <marin(dot)dimitrov(at)sirma(dot)bg> wrote:
>
> ----- Original Message -----
> From: <arnaud(dot)mlist1(at)free(dot)fr>
>
>
> >
> > And what I want to built a query that tells me if
> a word given in argument
> can
> > be found at least partially in the database.
> Something like
> >
> > select * from twords where words||'%' like
> 'saxophones';
> >
> > works but uses a sequential scan on the table...
> >
>
>
> try
>
http://techdocs.postgresql.org/techdocs/fulltextindexing.php
>
> hth,
>
> Marin
>
> ----
> "...what you brought from your past, is of no use in
> your present. When
> you must choose a new path, do not bring old
> experiences with you.
> Those who strike out afresh, but who attempt to
> retain a little of the
> old life, end up torn apart by their own memories. "
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the
> unregister command
> (send "unregister YourEmailAddressHere" to
majordomo(at)postgresql(dot)org)

__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tille, Andreas 2002-05-16 15:02:33 Assertion constraint replacement?
Previous Message Jeff Eckermann 2002-05-16 14:16:01 Re: books on pl/pgsql