Re: Speeds using a transaction vrs not

From: Richard Huxton <dev(at)archonet(dot)com>
To: Joel Fradkin <jfradkin(at)wazagua(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Speeds using a transaction vrs not
Date: 2005-02-24 14:21:04
Message-ID: 421DE2D0.9070601@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Mark Roberts 2005-02-24 15:02:35 Postgres 8 - Database access, new install.
Previous Message Przemyslaw Slupkowski 2005-02-24 14:20:48 Re: Software for database-visualisation