Re: Postgres and multiple updates in one statement

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>, Jamie Lawrence-Jenner <jamie(dot)jenner(at)autovhc(dot)co(dot)uk>, nha <lyondif02(at)free(dot)fr>, PgSQL-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Postgres and multiple updates in one statement
Date: 2009-07-27 17:39:41
Message-ID: 1248716381.14534.0.camel@jd-laptop.pragmaticzealot.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 2009-07-27 at 11:50 -0400, Tom Lane wrote:
> Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> writes:
> > On Mon, Jul 27, 2009 at 8:48 AM, Jamie
> > Lawrence-Jenner<jamie(dot)jenner(at)autovhc(dot)co(dot)uk> wrote:
> >> Our update statements are as follows
> >>
> >> Update table set col1=x,col2=y where pkid=1;
> >> Update table set col1=x,col2=y where pkid=2;
> >> Update table set col1=x,col2=y where pkid=3;
> >>
> >> Very simple and straight forward. Sometimes there could be as many as 50
> >> update statements to process.
>
> > Might as well fire them each as separate statements inside one
> > transaction, since pkid is unique and non-repeated in the updates.
>
> If they're all exactly the same pattern like that, it might be worth the
> trouble to set up a prepared statement.

Seems like an opportunity for the use of a function.

Joshua D. Drake

>
> regards, tom lane
>
--
PostgreSQL - XMPP: jdrake(at)jabber(dot)postgresql(dot)org
Consulting, Development, Support, Training
503-667-4564 - http://www.commandprompt.com/
The PostgreSQL Company, serving since 1997

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-07-27 17:49:41 Re: Calculating the difference between timetz values
Previous Message Bob Gobeille 2009-07-27 16:32:55 combining db's- importing primary keys