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 3A89553AD6 for ; Thu, 31 Mar 2005 20:58:34 +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 56474-06 for ; Thu, 31 Mar 2005 19:58:33 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.203]) by svr1.postgresql.org (Postfix) with ESMTP id 2875053A6C for ; Thu, 31 Mar 2005 20:58:30 +0100 (BST) Received: by rproxy.gmail.com with SMTP id j1so469690rnf for ; Thu, 31 Mar 2005 11:58:30 -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=JwqY/8WzORPZ8KKy0YxsZ7knxMvtrzIEuYUi1wBvv31VY+AIi+UJ9pbEKLcyS7ybf18FLUHHGIgHbS1mCA7WCQPZzWolJBkreN92Y91iWn1cN7soJ+xRmJydN6n4ZqefwAyFZ4pUY1NEA0qT1xeRdFMDR6LPr7RVj3zDFLoE6m4= Received: by 10.38.208.10 with SMTP id f10mr1702645rng; Thu, 31 Mar 2005 11:58:30 -0800 (PST) Received: by 10.38.82.47 with HTTP; Thu, 31 Mar 2005 11:58:30 -0800 (PST) Message-ID: Date: Thu, 31 Mar 2005 13:58:30 -0600 From: Yudie Pg Reply-To: Yudie Pg To: pgsql-performance@postgresql.org Subject: How to speed up word count in 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.239 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200503/689 X-Sequence-Number: 11394 (It is the 2nd posting, maybe the 1st one didn't goes thru) 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?