pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: dLux <dlux@kapu.hu>
To: pgsql-sql@postgresql.org
Subject: Help for performance
Date: Thu, 20 Jan 2000 12:54:58 +0100
Message-ID: <20000120125458.A14384@dlux.hu> (raw)

Hello!

  I have two tables:

  ns_article has about 2000 entries, and ns_word has about 2000000.

ns_word  is a  word-index  for  the article.  I  want  to implement  a
word-search in it.
I want  to implement a  search function,  which can search  with "like
'wordstart%'". I need  to do it with a lot of  keywords like altavista
does (with  +: intersect,  without +:  union; with  -: except),  but I
haven't found any fast result.

The following query tree would be good:
- sort by atime
  - index scan on ns_article (by article_id)
    hash join:
      - intersect/union/except
        - index scan on ns_word (by index_word)
        - index scan on ns_word (by index_word)
      ...

My current solution is:
(select  distinct atime(get_ns_article(article_id))  as a,  article_id
from  ns_word   where  index_word   like  'wordstart%')   union  (...)
intersect (...) order by a;

But this  is VERY slow  if I search with  more than one  keyword (when
intersect/union is  on use). It  is quite  fast for one  keyword (like
this:   select   distinct  atime(get_ns_article(article_id))   as   a,
article_id from ns_word where index_word like 'linux%').

the  get_ns_artcile is  a  function which  returns  a  tuple from  the
ns_article table by an article_id.

Please help me  to make it faster!  We have enough memory,  so this is
not a problem!

Thanks again,

dLux

--------------------------------------
Here are the table defs:
create table ns_article (
  article_id  int not null default nextval('ns_article_seq'),
  site   text,
  atime   timestamp,
  ...
);

create unique index ns_article_pkey on ns_article (article_id);
create unique index ns_article_url_title on ns_article (url,title);
create index ns_article_atime on ns_article (atime);

create table ns_word (
  article_id  int, -- cikk száma
  orig_word  text,
  index_word  text,
  word_position  int
);

create index ns_word_index_word on ns_word (index_word);
create  unique index  ns_word_article_wordpos on  ns_word (article_id,
word_position);

dLux
--
                             Tel: (+36)/30-9663314



Message-ID: <20000120125458.A14384@dlux.hu>
Permalink:  ../20000120125458.A14384@dlux.hu/
Also on:    postgresql.org/message-id/20000120125458.A14384@dlux.hu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: dlux@kapu.hu
  Subject: Re: Help for performance
  In-Reply-To: <20000120125458.A14384@dlux.hu>
  References: <20000120125458.A14384@dlux.hu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox