Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hDwlv-0008UC-36 for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Apr 2019 19:51:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hDwlt-0004Do-Rv for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Apr 2019 19:51:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hDwlt-00048Q-Fo for pgsql-hackers@lists.postgresql.org; Tue, 09 Apr 2019 19:51:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hDwlr-0004Cn-6x for pgsql-hackers@postgresql.org; Tue, 09 Apr 2019 19:51:04 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x39JonVR022901; Tue, 9 Apr 2019 15:50:50 -0400 From: Tom Lane To: Andrew Gierth cc: Andreas Karlsson , Tomas Vondra , Merlin Moncure , Alvaro Herrera , Peter Eisentraut , Michael Paquier , Robert Haas , Andres Freund , Thomas Munro , David Fetter , Pg Hackers Subject: Re: Early WIP/PoC for inlining CTEs In-reply-to: <6696.1551192698@sss.pgh.pa.us> References: <20190214160209.GA13250@alvherre.pgsql> <31353.1550351689@sss.pgh.pa.us> <62080f95-3934-4700-00ca-7c35630ab7a0@proxel.se> <87wolmg60q.fsf@news-spur.riddles.org.uk> <6696.1551192698@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 26 Feb 2019 09:51:38 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <22899.1554839449.1@sss.pgh.pa.us> Date: Tue, 09 Apr 2019 15:50:49 -0400 Message-ID: <22900.1554839449@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > Andrew Gierth writes: >> So what I think we need to do here is to forbid inlining if (a) the >> refcount is greater than 1 and (b) the CTE in question contains, >> recursively anywhere inside its rtable or the rtables of any of its >> nested CTEs, a "self_reference" RTE. > That's kind of "ugh" too: it sounds expensive, and doing it in a way > that doesn't produce false positives would be even more complicated. After further investigation, I concluded that that wasn't that awful, so done that way. I'm still not entirely convinced about the behavior for nested WITHs with different materialization specifications, but that seems like a separate topic. regards, tom lane