Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id C66D96502CA for ; Mon, 28 Jul 2008 13:34:01 -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 84923-09-2; Mon, 28 Jul 2008 13:33:39 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from oxford.xeocode.com (87-127-95-198.no-dns-yet.enta.net [87.127.95.198]) by postgresql.org (Postfix) with ESMTP id 8122F65038A; Mon, 28 Jul 2008 13:33:34 -0300 (ADT) Received: from localhost ([127.0.0.1] helo=oxford.xeocode.com) by oxford.xeocode.com with esmtp (Exim 4.69) (envelope-from ) id 1KNVf7-0008WL-RI; Mon, 28 Jul 2008 17:33:29 +0100 To: "Tom Lane" Cc: "Tatsuo Ishii" , , Subject: Re: WITH RECUSIVE patches 0723 In-Reply-To: <19882.1217256991@sss.pgh.pa.us> (Tom Lane's message of "Mon\, 28 Jul 2008 10\:56\:31 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) X-Draft-From: ("nnimap+mail01.enterprisedb.com:INBOX.hackers" 24999) 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> From: Gregory Stark Organization: EnterpriseDB Date: Mon, 28 Jul 2008 17:33:29 +0100 Message-ID: <878wvmt1d2.fsf@oxford.xeocode.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.1 tagged_above=0 required=5 tests=RDNS_DYNAMIC=0.1 X-Spam-Level: X-Archive-Number: 200807/1305 X-Sequence-Number: 121565 "Tom Lane" writes: "Tom Lane" writes: > I think what this is saying is that the subquery defined by a WITH > clause is to be evaluated only once, even if it is referenced in > multiple places in the upper query. This is sensible because if there > is no such rule, then there really is no semantic difference between > non-recursive WITH and ordinary subqueries; and the SQL committee is not > known for inventing duplicate syntax. Well I guess that answers the question of whether to apply the partial patch before full recursive queries come along. In any case since that work seems to be making a lot of progress (no thanks to me:( ) I don't think it's a problem to wait. > 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? Once we have that we'll just use those executor nodes even for non-recursive queries. -- Gregory Stark EnterpriseDB http://www.enterprisedb.com Ask me about EnterpriseDB's RemoteDBA services!