Re: Writeable CTEs and side effects

From: Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>
To: Marko Tiikkaja <marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Writeable CTEs and side effects
Date: 2009-10-07 21:22:21
Message-ID: 3073cc9b0910071422x24ba862ape0e6212d096e11c2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Oct 7, 2009 at 4:20 PM, Marko Tiikkaja
<marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi> wrote:
> Jaime Casanova wrote:
>>
>> On Wed, Oct 7, 2009 at 4:08 PM, Marko Tiikkaja
>> <marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi> wrote:
>>>
>>> 1)      WITH t AS
>>>       (UPDATE foo SET bar = bar+1 RETURNING *)
>>>       SELECT * FROM t LIMIT 1;
>>>
>>> What's problematic here is that only 1 row is read from the CTE, meaning
>>> also that only one row is updated which, at least how I see it, is not
>>> what we want.  The CTE should only store one row and return that after
>>> it has completely processed the UPDATE statement.
>>>
>>
>> i'm talking from my ignorance... but AFAIU this should process the
>> whole UPDATE and then form a WorkTable with the results...
>> what the select reads from that results is another thing...
>>
>
> Right.  This is exactly what I'm trying to do, except I think we could
> easily optimize this case and store only the first processed row inside
> the CTE.
>

why? we don't should be thinking in optimizations in this phase

--
Atentamente,
Jaime Casanova
Soporte y capacitación de PostgreSQL
Asesoría y desarrollo de sistemas
Guayaquil - Ecuador
Cel. +59387171157

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marko Tiikkaja 2009-10-07 21:27:47 Re: Writeable CTEs and side effects
Previous Message Marko Tiikkaja 2009-10-07 21:20:20 Re: Writeable CTEs and side effects