Re: postgresql multiple insert slow

From: Christopher Browne <cbbrowne(at)acm(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: postgresql multiple insert slow
Date: 2004-02-21 15:03:53
Message-ID: m3ad3cpj8m.fsf@wolfe.cbbrowne.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Centuries ago, Nostradamus foresaw when mich(at)freebsdcluster(dot)org ("Michael L. Hostbaek") would write:
> I runs fine - and I get no errors - but it takes almost 25 minutes to
> complete.. I tried running the script while just grabbing the rows from
> the oracle database and writing to a text file - and then it only takes
> a couple of minutes .. So it must be the INSERT command that chokes - is
> there a better way to do it ?
>
> Any advise much appreciated.

The problem here is that each insert implicitly sets up a transaction
BEGIN and COMMIT.

If you were to wrap the loop with a BEGIN at the start and a COMMIT at
the end, you would likely find it would complete much, much faster.
--
output = ("cbbrowne" "@" "acm.org")
http://www3.sympatico.ca/cbbrowne/wp.html
"Java and C++ make you think that the new ideas are like the old ones.
Java is the most distressing thing to hit computing since MS-DOS."
-- Alan Kay

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2004-02-21 16:03:45 Re: postgresql multiple insert slow
Previous Message V i s h a l Kashyap @ [Sai Hertz And Control Systems] 2004-02-21 08:12:37 Re: Function