Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 2424D633408 for ; Mon, 7 Jun 2010 13:52:24 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 74839-06 for ; Mon, 7 Jun 2010 16:52:12 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from 27.mail-out.ovh.net (27.mail-out.ovh.net [91.121.30.210]) by mail.postgresql.org (Postfix) with SMTP id 23B5763313D for ; Mon, 7 Jun 2010 13:52:11 -0300 (ADT) Received: (qmail 18947 invoked by uid 503); 7 Jun 2010 16:55:23 -0000 Received: from b6.ovh.net (HELO mail195.ha.ovh.net) (213.186.33.56) by 27.mail-out.ovh.net with SMTP; 7 Jun 2010 16:55:23 -0000 Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 7 Jun 2010 18:52:10 +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; 7 Jun 2010 18:52:10 +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: Mon, 07 Jun 2010 18:52:07 +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: 2574370137871025906 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/133 X-Sequence-Number: 38989 > 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). With a different distribution, ie duplicates only between existing and imported data, and not within the imported data, this strategy would be useless.