Re: PL/pgSQL 2

From: Joel Jacobson <joel(at)trustly(dot)com>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: Kevin Grittner <kgrittn(at)ymail(dot)com>, Marko Tiikkaja <marko(at)joh(dot)to>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PL/pgSQL 2
Date: 2014-09-02 16:55:01
Message-ID: CAASwCXdZq5Hg2LS+Sc3kaeTcFXYysphLj2mmi4vQnBPk+32X4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Sep 2, 2014 at 6:31 PM, Heikki Linnakangas
<hlinnakangas(at)vmware(dot)com> wrote:
> I don't think most applications are like that. See Kevin's comments about
> doing things in a set-oriented way instead of row-by-row. I know I've
> changed several procedures from the row-oriented style, looping over rows
> with a FOR loop, updating each one individually, to set-oriented style with
> a single UPDATE for a bunch of rows. It makes for more concise code, and
> performs better. I'm sure there are counter-examples, and I've also written
> many UPDATE statements that are expected to update exactly one row, but I
> find an ASSERT would be adequate for that.

I'm *not* doing FOR-loops with UPDATE of single rows. I typically have
functions which have an input variable, which maps to a primary key in
a table, and the UPDATE is made on that single row. This is a
simplificaiton, but the main point is that the typical use case is
*not* FOR-loops.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Joel Jacobson 2014-09-02 16:57:42 Re: PL/pgSQL 2
Previous Message Marko Tiikkaja 2014-09-02 16:51:24 Re: PL/pgSQL 2