On 9/2/14 6:31 PM, Heikki Linnakangas wrote:
On 09/02/2014 07:12 PM, Joel Jacobson wrote:
For me, updating a row, is like setting a variable in a normal language.
No normal language would require two rows to set a variable.
It would be like having to do:
     my $var = 10;
     die unless $var == 10;
in Perl to set a variable.

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.

Well, just off the top of my head a normal function invocation could be: one worker working on a single "order" started by a single end user to transfer money from one account to another. And we have *a lot* of code like this where there isn't a way to write the code in "set-oriented style" without inventing a time machine. Which just might be out of the scope of plpgsql2 (or perhaps as a GUC).


Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to