tsearch2: very slow queries - Mailing list pgsql-general

From Marc G. Fournier
Subject tsearch2: very slow queries
Date
Msg-id 20050807164130.Q1002@ganymede.hub.org
Whole thread Raw
Responses Re: tsearch2: very slow queries  ("Joshua D. Drake" <jd@commandprompt.com>)
List pgsql-general
'k, I'm obviously doing something wrong, since my experiences with sites
like fts.postgresql.org indicate things should be *alot* faster then I'm
getting ...

I have a *very* simple table:

=# \d article_tsearch
   Table "public.article_tsearch"
    Column   |   Type   | Modifiers
------------+----------+-----------
  article_id | integer  |
  idxft1     | tsvector |
Indexes:
     "at_idxft1_idx" gist (idxft1)

rblog=# select count(1) from article_tsearch;
  count
--------
  643072
(1 row)

rblog=# select count(1) from article_tsearch where idxFT1 @@ to_tsquery('1&dvd');;
  count
-------
   1681
(1 row)

But, it just seems to take so long to do the query itself:

# explain analyze select * from article_tsearch where idxFT1 @@ to_tsquery('1&dvd') order by rank(idxFT1,
to_tsquery('1&dvd'))desc limit 26; 
                                                                        QUERY PLAN

---------------------------------------------------------------------------------------------------------------------------------------------------------
  Limit  (cost=2625.53..2625.60 rows=26 width=36) (actual time=20164.262..20164.597 rows=26 loops=1)
    ->  Sort  (cost=2625.53..2627.14 rows=644 width=36) (actual time=20164.257..20164.298 rows=26 loops=1)
          Sort Key: rank(idxft1, '\'1\' & \'dvd\''::tsquery)
          ->  Index Scan using at_idxft1_idx on article_tsearch  (cost=0.00..2595.48 rows=644 width=36) (actual
time=29.476..20153.530rows=1681 loops=1) 
                Index Cond: (idxft1 @@ '\'1\' & \'dvd\''::tsquery)
                Filter: (idxft1 @@ '\'1\' & \'dvd\''::tsquery)
  Total runtime: 20166.326 ms
(7 rows)

If it is, then I'm obviously overlooking something key here ... now, I've
read through the docs in contrib/tsearch2/docs, and don't *think* I've
missed anything obvious ... it seems fairly straightforward ...

Is there something else I should be doing to speed the query up any?  Or
is this fairly normal?

----
Marc G. Fournier           Hub.Org Networking Services (http://www.hub.org)
Email: scrappy@hub.org           Yahoo!: yscrappy              ICQ: 7615664

pgsql-general by date:

Previous
From: Christopher Browne
Date:
Subject: Re: postgresql Secure Mode
Next
From: "Joshua D. Drake"
Date:
Subject: Re: tsearch2: very slow queries