Re: in Pl/PgSQL, do commit every 5000 records

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Emi Lu <emilu(at)encs(dot)concordia(dot)ca>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: in Pl/PgSQL, do commit every 5000 records
Date: 2006-03-10 15:56:01
Message-ID: 20060310155601.GA21877@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Mar 10, 2006 at 09:36:16 -0500,
Emi Lu <emilu(at)encs(dot)concordia(dot)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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Emi Lu 2006-03-10 16:06:04 Re: in Pl/PgSQL, do commit every 5000 records
Previous Message Emi Lu 2006-03-10 15:46:39 About updates