Re: Help with many updates

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Glenn MacGregor <gtm(at)oracom(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Help with many updates
Date: 2002-02-21 21:09:42
Message-ID: 1014325782.3217.823.camel@linda
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, 2002-02-21 at 16:31, Glenn MacGregor wrote:
> What is the preferred way to do many updates. Right now I am just doing
> each row at a time, is there a better way? I have about 1000 or so and it
> takes a good 45 seconds

If you are currently doing:

INSERT...
INSERT...

you can speed it up by enclosing the whole lot in a single transaction:

BEGIN
INSERT...
INSERT...
COMMIT

You can get it even faster by formatting the input data in a text file
and using the COPY command (not in a transaction).

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C

"My sheep hear my voice, and I know them, and they
follow me; And I give unto them eternal life; and they
shall never perish, neither shall any man pluck them
out of my hand." John 10:27,28

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Erik Norvelle 2002-02-21 21:13:40 Re: Trying to convert a TIMESTAMP return value to TIME
Previous Message Richard Emberson 2002-02-21 20:17:08 Finding matching columns from two tables