X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2C4D9534D3 for ; Thu, 31 Mar 2005 19:52:52 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39484-01 for ; Thu, 31 Mar 2005 18:52:50 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.193]) by svr1.postgresql.org (Postfix) with ESMTP id D45B452D44 for ; Thu, 31 Mar 2005 19:52:48 +0100 (BST) Received: by rproxy.gmail.com with SMTP id j1so454428rnf for ; Thu, 31 Mar 2005 10:52:49 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=a63Et7LypbyOOGNNcxrmFgd096F7GjGaP9+x81Y3IVDgfFL2AyQGtzUEwS8asCZ2x1zorDiaJHGu88dqkeCil9i3Kxrny2dvkOc8IREEZ1kVvyhplGlWdc8cW1JnjLJ03VtlsA4vTLxJB3NEiXZetqgb8PWueUIbQ6ThsDGrywo= Received: by 10.38.79.42 with SMTP id c42mr1621512rnb; Thu, 31 Mar 2005 10:52:49 -0800 (PST) Received: by 10.38.82.47 with HTTP; Thu, 31 Mar 2005 10:52:48 -0800 (PST) Message-ID: Date: Thu, 31 Mar 2005 12:52:48 -0600 From: Yudie Pg Reply-To: Yudie Pg To: pgsql-performance@postgresql.org Subject: How to speed up word count with tsearch2? Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.235 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200503/685 X-Sequence-Number: 11390 I've tested several keyword count from 2 millions record book description table that indexed with tseach2 indexing. The result is always slow for first query attempt. This my sample query: -- test one phrase -- SELECT count(*) from table1 WHEREsearchvector @@ to_tsquery('default' ,'david') limit 100 :: returns 16824 records match. :: take 49618.341 ms (1st attempt) :: take 504.229 ms (2nd attempt) -- test two phrase -- SELECT count(*) from table1 WHERE searchvector @@ to_tsquery('default' ,'martha&stewart') limit 100 :: returns 155 records match. :: take 686.669 ms (1st attempt) :: take 40.282 ms (2nd attempt) I use ordinary aggregate function count(*), Is there other way to count faster?