Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id CBD379FB566 for ; Wed, 23 May 2007 05:04:31 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 20288-04 for ; Wed, 23 May 2007 05:04:26 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.168]) by postgresql.org (Postfix) with ESMTP id 3A53E9FB3CA for ; Wed, 23 May 2007 05:04:26 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id 74so431816ugb for ; Wed, 23 May 2007 01:04:24 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=i/kpj7ln1onstdQzE+iyzFsQbT+R786teJBRnWtRm9YWROeM/TUyuMpBm/VUH5QHR9w5vHHfRutvPnpwdBTTIBX4SpwIDrF2JeMR/I3RVV6K9Ay57WrfgVDUPvghPyvd81K0wAhi+7ZSXcePGFj2RS1JV/+uY0rqchR858L6NR0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=lZ35IhpvGmNGAB0kmagsixbcSlCfWlBD/K8Rvkt8hgl/SDzSOV3PMhnMhv8RkDKhnNR0XLtarK13aV/1tz4v3wCh14mkeGd18uuVBdGII1+dNECo4lGcfC8wW+RmPFpMYxmqxuievqw0hO+FqUuopGBnkfYNKQvTur2oxnOOQkg= Received: by 10.82.184.2 with SMTP id h2mr541184buf.1179907464766; Wed, 23 May 2007 01:04:24 -0700 (PDT) Received: by 10.82.118.6 with HTTP; Wed, 23 May 2007 01:04:24 -0700 (PDT) Message-ID: <1d4e0c10705230104o30db1cf6x86207a96b23f823a@mail.gmail.com> Date: Wed, 23 May 2007 10:04:24 +0200 From: "Guillaume Smet" To: cedric Subject: Re: Key/Value reference table generation: INSERT/UPDATE performance Cc: pgsql-performance@postgresql.org, "Richard Huxton" , valgog In-Reply-To: <200705221428.09546.cedric.villemain@dalibo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1179822183.740891.271130@n59g2000hsh.googlegroups.com> <4652B627.1070109@archonet.com> <200705221428.09546.cedric.villemain@dalibo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/447 X-Sequence-Number: 24837 On 5/22/07, cedric wrote: > I made something very similar, and using PL/pgsql is very slow, when using > perl is very quick. Another solution is to use tsearch2 for that: CREATE TABLE word_counts AS SELECT * FROM stat('SELECT to_tsvector(''simple'', lower(coalesce(field containing words, ''''))) FROM your table'); I don't know if the fact you have an array of words is a must have or just a design choice. If you have to keep that, you can transform the array easily into a string with array_to_string and use the same sort of query. I don't know what are exactly your speed requirements but it's quite fast here. If you drop your table and recreate it into a transaction, it should work like a charm (or you can use TRUNCATE and INSERT INTO). -- Guillaume