Re: Writeable CTEs and side effects

From: Marko Tiikkaja <marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Writeable CTEs and side effects
Date: 2009-10-08 11:02:41
Message-ID: 4ACDC6D1.7000703@cs.helsinki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas wrote:
> This has one MAJOR disadvantage: all the tuples from the CTE queries
> have to be buffered someplace, rather than streamed from the subquery
> up to the main query. For what may turn out to be pretty common uses
> cases like WITH tuples AS (DELETE FROM big_table_1 RETURNING ...)
> INSERT INTO big_table_2 ... this is going to suck pretty bad. I
> wonder if it isn't better to just use the same command-ID throughout
> and live with the weirdness of #2.

I haven't looked at the CTE code in much detail but I was under the
impression that it had to store the results somewhere in any case.
You're right, though, it sucks for this use case. Weirdness of #2 is
probably a lot easier to live with.

> I think you should definitely get some input from Tom Lane on this
> before you go too much further, but if he doesn't respond to this
> thread, I suggest trying again after CommitFest.

Agreed.

> Does this have any impact on the pending DML-node patch?

Not really. This could be done without the patch, but we can use far
more of the existing CTE code with the patch.

Regards,
Marko Tiikkaja

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Boszormenyi Zoltan 2009-10-08 11:15:58 Re: Review of "SQLDA support for ECPG"
Previous Message Robert Haas 2009-10-08 10:52:41 Re: Writeable CTEs and side effects