X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id CE1DE9DC818 for ; Thu, 29 Dec 2005 10:41:07 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 34801-02 for ; Thu, 29 Dec 2005 10:41:12 -0400 (AST) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id DA51E9DC817 for ; Thu, 29 Dec 2005 10:41:05 -0400 (AST) Received: from lou-bada.torma.org (lou-bada.torma.org [213.41.177.64]) by svr4.postgresql.org (Postfix) with ESMTP id CA8495AFEDA for ; Thu, 29 Dec 2005 14:41:10 +0000 (GMT) Received: from lara.torma.org (lara.lou-bada.torma.org [10.7.3.65]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lou-bada.torma.org (Postfix) with ESMTP id 74E315DB63 for ; Thu, 29 Dec 2005 15:41:07 +0100 (CET) From: Teemu Torma To: pgsql-performance@postgresql.org Subject: Re: How import big amounts of data? Date: Thu, 29 Dec 2005 15:41:05 +0100 User-Agent: KMail/1.9.1 References: <43B3B0EA.6070406@andromeiberica.com> In-Reply-To: <43B3B0EA.6070406@andromeiberica.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200512291541.05739.teemu@torma.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200512/647 X-Sequence-Number: 16468 On Thursday 29 December 2005 10:48, Arnau wrote: > Which is the best way to import data to tables? I have to import > 90000 rows into a column and doing it as inserts takes ages. Would be > faster with copy? is there any other alternative to insert/copy? I am doing twice as big imports daily, and found the follwing method most efficient (other than using copy): - Use plpgsql function to do the actual insert (or update/insert if needed). - Inside a transaction, execute SELECT statements with maximum possible number of insert function calls in one go. This minimizes the number of round trips between the client and the server. Teemu