X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 045F355DB1 for ; Thu, 24 Feb 2005 14:20:59 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41095-09 for ; Thu, 24 Feb 2005 14:20:58 +0000 (GMT) Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net [194.217.242.92]) by svr1.postgresql.org (Postfix) with ESMTP id DA6C855BD0 for ; Thu, 24 Feb 2005 14:20:57 +0000 (GMT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-34.mail.demon.net with esmtp (Exim 4.42) id 1D4JrV-0003u8-EX; Thu, 24 Feb 2005 14:21:05 +0000 Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id B2E3715A56; Thu, 24 Feb 2005 14:21:03 +0000 (GMT) Message-ID: <421DE2D0.9070601@archonet.com> Date: Thu, 24 Feb 2005 14:21:04 +0000 From: Richard Huxton User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Joel Fradkin Cc: pgsql-sql@postgresql.org Subject: Re: Speeds using a transaction vrs not References: <001b01c51a77$f704e250$797ba8c0@jfradkin> In-Reply-To: <001b01c51a77$f704e250$797ba8c0@jfradkin> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.063 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200502/302 X-Sequence-Number: 20412 Joel Fradkin wrote: > No I did not do it in on transaction (although in .net I never started or > commited a transaction. All inserts/updates/etc take place within a transaction with PostgreSQL. Some client libraries autocommit for you - you'll need to read the documentation. > ODBC : > myCommand.CommandText = insertsqltext > myCommand.ExecuteNonQuery() > myTrans.Commit() > > .net driver: > Dim cmd As New NpgsqlCommand(insertsqltext, cnn) > cmd.ExecuteNonQuery() > cmd.Dispose() Both look to me like they are producing one transaction per insert (the slowest possible way to bulk-copy data). That's assuming each block of commands is within one loop. Precisely what is happening will be easiest to see by turning statement logging on in your postgresql.conf and comparing two runs. The delay might be in overheads of setting up the transaction etc. with the ODBC driver. In any case, if bulk-copying data you'll find a huge improvement grouping rows together in batches of 100 - 10,000. -- Richard Huxton Archonet Ltd