tsearch2: very slow queries

From: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: tsearch2: very slow queries
Date: 2005-08-07 20:54:04
Message-ID: 20050807164130.Q1002@ganymede.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.530 rows=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(at)hub(dot)org Yahoo!: yscrappy ICQ: 7615664

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2005-08-07 21:18:07 Re: tsearch2: very slow queries
Previous Message Poul Møller Hansen 2005-08-07 19:44:53 Re: Remopte connection to POstgreSQL via ODBC