Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id D3BC263232B for ; Wed, 9 Jun 2010 07:51:39 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 26601-07 for ; Wed, 9 Jun 2010 10:51:20 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from 30.mail-out.ovh.net (30.mail-out.ovh.net [213.186.62.213]) by mail.postgresql.org (Postfix) with SMTP id F20BB6321D2 for ; Wed, 9 Jun 2010 07:51:19 -0300 (ADT) Received: (qmail 30591 invoked by uid 503); 9 Jun 2010 10:44:31 -0000 Received: from b9.ovh.net (HELO mail632.ha.ovh.net) (213.186.33.59) by 30.mail-out.ovh.net with SMTP; 9 Jun 2010 10:44:31 -0000 Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 9 Jun 2010 12:51:16 +0200 Received: from par69-8-88-161-102-87.fbx.proxad.net (HELO apollo13) (lists%peufeu.com@88.161.102.87) by ns0.ovh.net with SMTP; 9 Jun 2010 12:51:14 +0200 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: =?utf-8?Q?Torsten_Z=C3=BChlsdorff?= , pgsql-performance@postgresql.org Subject: Re: How to insert a bulk of data with unique-violations very fast References: <4C07E418.80103@meisterderspiele.de> Date: Wed, 09 Jun 2010 12:51:08 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Pierre C" Message-ID: In-Reply-To: User-Agent: Opera Mail/10.10 (Linux) X-Ovh-Tracer-Id: 8224135870504699634 X-Ovh-Remote: 88.161.102.87 (par69-8-88-161-102-87.fbx.proxad.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|U 0.5/N X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.001 tagged_above=-10 required=5 tests=BAYES_40=-0.001, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201006/135 X-Sequence-Number: 38991 >>> Within the data to import most rows have 20 till 50 duplicates. >>> Sometime much more, sometimes less. >> In that case (source data has lots of redundancy), after importing the >> data chunks in parallel, you can run a first pass of de-duplication on >> the chunks, also in parallel, something like : >> CREATE TEMP TABLE foo_1_dedup AS SELECT DISTINCT * FROM foo_1; >> or you could compute some aggregates, counts, etc. Same as before, no >> WAL needed, and you can use all your cores in parallel. >> From what you say this should reduce the size of your imported data >> by a lot (and hence the time spent in the non-parallel operation). > > Thank you very much for this advice. I've tried it inanother project > with similar import-problems. This really speed the import up. Glad it was useful ;)