Re: in Pl/PgSQL, do commit every 5000 records - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: in Pl/PgSQL, do commit every 5000 records
Date
Msg-id 20060310155601.GA21877@wolff.to
Whole thread Raw
In response to in Pl/PgSQL, do commit every 5000 records  (Emi Lu <emilu@encs.concordia.ca>)
Responses Re: in Pl/PgSQL, do commit every 5000 records  (Emi Lu <emilu@encs.concordia.ca>)
List pgsql-general
On Fri, Mar 10, 2006 at 09:36:16 -0500,
  Emi Lu <emilu@encs.concordia.ca> wrote:
> Good morning,
>
> In a plpgsql function, I am trying to insert 900, 000 records into
> several tables. I remembered people mentioned before that it is better
> and more efficient to commit actions for let's say every 5000 records'
> insertion.

You can't do commits inside of a function. I think you are misremembering
advice about not do inserts with a transaction per row which will have
a lot of overhead for all of the commits.

You can do savepoints inside of a function, but those are going to slow things
down, not speed them up.

pgsql-general by date:

Previous
From: Emi Lu
Date:
Subject: About updates
Next
From: Emi Lu
Date:
Subject: Re: in Pl/PgSQL, do commit every 5000 records