Re: postgresql multiple insert slow - Mailing list pgsql-sql

From Christopher Browne
Subject Re: postgresql multiple insert slow
Date
Msg-id m3ad3cpj8m.fsf@wolfe.cbbrowne.com
Whole thread Raw
In response to postgresql multiple insert slow  ("Michael L. Hostbaek" <mich@freebsdcluster.org>)
List pgsql-sql
Centuries ago, Nostradamus foresaw when mich@freebsdcluster.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


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Function
Next
From: elein
Date:
Subject: Re: searching polygons