Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id A13C8650292 for ; Mon, 28 Jul 2008 13:44:34 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 96496-06 for ; Mon, 28 Jul 2008 13:44:27 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 917D865018D for ; Mon, 28 Jul 2008 13:44:28 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m6SGiOx2022970; Mon, 28 Jul 2008 12:44:24 -0400 (EDT) To: Gregory Stark cc: "Tatsuo Ishii" , andrew@tao11.riddles.org.uk, pgsql-hackers@postgresql.org Subject: Re: WITH RECUSIVE patches 0723 In-reply-to: <878wvmt1d2.fsf@oxford.xeocode.com> References: <20080725001513.GF16438@fetter.org> <20080725.092652.105178884.t-ishii@sraoss.co.jp> <87r69gs967.fsf@news-spur.riddles.org.uk> <20080728.162925.23020498.t-ishii@sraoss.co.jp> <19882.1217256991@sss.pgh.pa.us> <878wvmt1d2.fsf@oxford.xeocode.com> Comments: In-reply-to Gregory Stark message dated "Mon, 28 Jul 2008 17:33:29 +0100" Date: Mon, 28 Jul 2008 12:44:24 -0400 Message-ID: <22969.1217263464@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200807/1306 X-Sequence-Number: 121566 Gregory Stark writes: > "Tom Lane" writes: >> This isn't going to be a particularly simple fix :-(. The basic >> implementation clearly ought to be to dump the result of the subquery >> into a tuplestore and then have the upper level read out from that. >> However, we don't have any infrastructure for having multiple >> upper-level RTEs reference the same tuplestore. > Uhm, indeed, isn't that the whole point of the work needed to make recursive > queries work? No, I don't think so. The present patch (so far as I've gathered what it can do, in the absence of any documentation) knows how to feed back tuples collected at an upper level to a scan node at a lower level, which is needed to implement recursion. However, if you do WITH RECURSIVE foo AS (...) SELECT ... FROM foo a, foo b WHERE then you will still get two independent evaluations of duplicate querytrees. Which is at least a performance bug, and if there are any volatile functions inside foo I claim it's a spec violation too. regards, tom lane