Re: wCTE: why not finish sub-updates at the end, not the beginning?

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Marko Tiikkaja <marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: wCTE: why not finish sub-updates at the end, not the beginning?
Date: 2011-02-25 17:36:31
Message-ID: AANLkTim4R685tcmdmn-mBrdC-0BXYDqOqSoGrfvd4Um9@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Feb 25, 2011 at 11:31 AM, Greg Stark <gsstark(at)mit(dot)edu> wrote:
> On Fri, Feb 25, 2011 at 2:58 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> However, the real reason for doing it isn't any of those, but rather
>> to establish the principle that the executions of the modifying
>> sub-queries are interleaved not sequential.  We're never going to be
>> able to do any significant optimization of such queries if we have to
>> preserve the behavior that the sub-queries execute sequentially.
>> And I think it's inevitable that users will manage to build such an
>> assumption into their queries if the first release with the feature
>> behaves that way.
>
> Does the interleaved execution have sane semantics?
>
> With a query like:
>
> WITH
>  a as update x set x.i=x.i+1 returning x.i,
>  b as update x set x.i=x.i+1 returning x.i
> select * from a natural join b;
>
> Is there any way to tell what it will return or what state it will
> leave the table in?

WITH
a as update x set x.i=x.i+1 returning x.i,
b as update x set x.i=x.i+1 where x.i = 1 returning x.i
select * from a natural join b;

or the above if x is.i is 1 for all x on query start?

merlin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-02-25 17:50:51 Re: WIP: cross column correlation ...
Previous Message Greg Stark 2011-02-25 17:31:05 Re: wCTE: why not finish sub-updates at the end, not the beginning?