Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id A04FA9FB4D2; Fri, 5 Oct 2007 05:10:37 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 66677-04; Fri, 5 Oct 2007 05:10:25 -0300 (ADT) X-Greylist: delayed 00:19:56.351029 by SQLgrey-1.7.5 X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sumo.dreamhost.com (sumo.dreamhost.com [66.33.216.29]) by postgresql.org (Postfix) with ESMTP id C0BF09FA639; Fri, 5 Oct 2007 05:10:27 -0300 (ADT) Received: from spunkymail-a9.g.dreamhost.com (sd-green-bigip-74.dreamhost.com [208.97.132.74]) by sumo.dreamhost.com (Postfix) with ESMTP id E333E187D15; Fri, 5 Oct 2007 00:50:27 -0700 (PDT) Received: from [192.168.1.110] (adsl-75-31-202-116.dsl.irvnca.sbcglobal.net [75.31.202.116]) by spunkymail-a9.g.dreamhost.com (Postfix) with ESMTP id 83B622112C; Fri, 5 Oct 2007 00:50:22 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v752.3) Content-Transfer-Encoding: 7bit Message-Id: Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed To: PostgreSQL , pgsql-performance@postgresql.org From: Benjamin Arai Subject: Slow TSearch2 performance for table with 1 million documents. Date: Fri, 5 Oct 2007 00:50:17 -0700 X-Mailer: Apple Mail (2.752.3) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/280 X-Sequence-Number: 121572 Hi, I have very slow performance for a TSearch2 table. I have pasted the EXPLAIN ANALYZE queries below. 12 seconds is slow for almost any purpose. Is there any way to speed this up? # explain analyze select * FROM fulltext_article, to_tsquery ('simple','dog') AS q WHERE idxfti @@ q ORDER BY rank(idxfti, q) DESC; QUERY PLAN ------------------------------------------------------------------------ ------------------------------------------------------------------------ ------------ Sort (cost=6576.74..6579.07 rows=933 width=774) (actual time=12969.237..12970.490 rows=5119 loops=1) Sort Key: rank(fulltext_article.idxfti, q.q) -> Nested Loop (cost=3069.79..6530.71 rows=933 width=774) (actual time=209.513..12955.498 rows=5119 loops=1) -> Function Scan on q (cost=0.00..0.01 rows=1 width=32) (actual time=0.005..0.006 rows=1 loops=1) -> Bitmap Heap Scan on fulltext_article (cost=3069.79..6516.70 rows=933 width=742) (actual time=209.322..234.390 rows=5119 loops=1) Recheck Cond: (fulltext_article.idxfti @@ q.q) -> Bitmap Index Scan on fulltext_article_idxfti_idx (cost=0.00..3069.56 rows=933 width=0) (actual time=208.373..208.373 rows=5119 loops=1) Index Cond: (fulltext_article.idxfti @@ q.q) Total runtime: 12973.035 ms (9 rows) # select count(*) from fulltext_article; count -------- 933001 (1 row) # select COUNT(*) FROM fulltext_article, to_tsquery('simple','blue & green') AS q WHERE idxfti @@ q; count ------- 6308 (1 row) Benjamin