Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id CE31B632939 for ; Mon, 7 Jun 2010 10:45:48 -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 55384-03 for ; Mon, 7 Jun 2010 13:45:41 +0000 (UTC) Received: from news.hub.org (news.hub.org [200.46.204.72]) by mail.postgresql.org (Postfix) with ESMTP id 895906328BD for ; Mon, 7 Jun 2010 10:45:41 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.4/8.14.4) with ESMTP id o57DjWQj061383 for ; Mon, 7 Jun 2010 10:45:32 -0300 (ADT) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.4/8.14.4/Submit) id o57DL9QV073894 for pgsql-performance@postgresql.org; Mon, 7 Jun 2010 10:21:09 -0300 (ADT) (envelope-from news) From: =?UTF-8?B?VG9yc3RlbiBaw7xobHNkb3JmZg==?= X-Newsgroups: pgsql.performance Subject: Re: How to insert a bulk of data with unique-violations very fast Date: Mon, 07 Jun 2010 15:21:13 +0200 Organization: A noiseless patient Spider Lines: 54 Message-ID: References: <4C07E418.80103@meisterderspiele.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 7 Jun 2010 13:21:14 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="AnkPUomeHXvuN7UdHvIkog"; logging-data="29414"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+C4kCG7iroJLt9cG96jC96" User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.8.1.24) Gecko/20100228 Thunderbird/2.0.0.24 Mnenhy/0.7.5.0 In-Reply-To: Cancel-Lock: sha1:I0UAh0BYM5PJS7lWIF0+EA9Oqpw= To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.79 tagged_above=-10 required=5 tests=BAYES_50=0.8, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201006/132 X-Sequence-Number: 38988 Pierre C schrieb: > Since you have lots of data you can use parallel loading. > > Split your data in several files and then do : > > CREATE TEMPORARY TABLE loader1 ( ... ) > COPY loader1 FROM ... > > Use a TEMPORARY TABLE for this : you don't need crash-recovery since if > something blows up, you can COPY it again... and it will be much faster > because no WAL will be written. That's a good advice, thank yo :) > If your disk is fast, COPY is cpu-bound, so if you can do 1 COPY process > per core, and avoid writing WAL, it will scale. > > This doesn't solve the other half of your problem (removing the > duplicates) which isn't easy to parallelize, but it will make the COPY > part a lot faster. > > Note that you can have 1 core process the INSERT / removing duplicates > while the others are handling COPY and filling temp tables, so if you > pipeline it, you could save some time. > > Does your data contain a lot of duplicates, or are they rare ? What > percentage ? Within the data to import most rows have 20 till 50 duplicates. Sometime much more, sometimes less. But over 99,1% of the rows to import are already know. This percentage is growing, because there is a finite number of rows i want to know. In my special case i'm collection domain-names. Till now it's completly for private interests and with normal pc-hardware. I'm collecting them by crawling known sites and checking them for new hosts. Maybe i will build later an expired domain service or an reverse ip database or something like that. But now i'm just interested in the connection of the sites and the structure people choose domain-names. (Before someone ask: Till now i have more rows than domains (nearly) exists, because i collect subdomain of all levels too and do not delete entries) Thanks everyone for your advices. This will help me a lot! Greetings from Germany, Torsten -- http://www.dddbl.de - ein Datenbank-Layer, der die Arbeit mit 8 verschiedenen Datenbanksystemen abstrahiert, Queries von Applikationen trennt und automatisch die Query-Ergebnisse auswerten kann.