Postgres and multiple updates in one statement

From: "Jamie Lawrence-Jenner" <jamie(dot)jenner(at)autovhc(dot)co(dot)uk>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Postgres and multiple updates in one statement
Date: 2009-07-27 08:10:02
Message-ID: !&!AAAAAAAAAAAYAAAAAAAAACSjyZCDEbJLs7GIuOJ8tGbCgAAAEAAAAN23KwkdXSpGjZZEv3dLuNgBAAAAAA==@autovhc.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi there

We have a function which runs a set of update clauses and we are considering
putting all the update clauses into one statement.

I would like to understand how postgres handles multiple updates. If we were
to send 5 update statements in one sql statement to the db would it:

Do 5 passes on the table, on each pass, retrieve the id then update the row

Do 1 pass to retrieve the 5 primary keys, then update all rows in parallel

Apart from saving on the overhead of having to open up 5 separate
connections, what are the benefits to passing in multiple updates in one
statement?

Many thanks,

Jamie

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2009-07-27 08:12:09 Re: Server/Client Encoding Errors
Previous Message Alvaro Herrera 2009-07-27 03:35:42 Re: Copying only incremental records to another DB..