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 1gnmG4-00043B-0p for pgsql-hackers@arkaria.postgresql.org; Sun, 27 Jan 2019 15:22:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gnmG2-00025p-S9 for pgsql-hackers@arkaria.postgresql.org; Sun, 27 Jan 2019 15:22:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gnmG2-00025i-Kz for pgsql-hackers@lists.postgresql.org; Sun, 27 Jan 2019 15:22:02 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gnmG0-0007R0-Nf for pgsql-hackers@postgresql.org; Sun, 27 Jan 2019 15:22:02 +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 x0RFLtvE000745; Sun, 27 Jan 2019 10:21:55 -0500 From: Tom Lane To: Andrew Gierth cc: Andreas Karlsson , David Fetter , Thomas Munro , Pg Hackers Subject: Re: Early WIP/PoC for inlining CTEs In-reply-to: <87fttejl62.fsf@news-spur.riddles.org.uk> References: <87sh48ffhb.fsf@news-spur.riddles.org.uk> <20180725054236.GB17411@fetter.org> <87bmavfjhy.fsf@news-spur.riddles.org.uk> <20180725191447.GE17411@fetter.org> <20180727081058.GN17411@fetter.org> <8810.1542402910@sss.pgh.pa.us> <87r2dxrw1z.fsf@news-spur.riddles.org.uk> <29ce1707-0dae-ad33-8ab0-7d5226c7dfd3@proxel.se> <11140.1548454956@sss.pgh.pa.us> <31065.1548543317@sss.pgh.pa.us> <87fttejl62.fsf@news-spur.riddles.org.uk> Comments: In-reply-to Andrew Gierth message dated "Sun, 27 Jan 2019 13:22:57 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <743.1548602515.1@sss.pgh.pa.us> Date: Sun, 27 Jan 2019 10:21:55 -0500 Message-ID: <744.1548602515@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andrew Gierth writes: > I'm not sure we should nail down the rule that the absence of NOT > MATERIALIZED will mean a multiply-referenced CTE is evaluated once. One > would hope that in the future the planner might be taught to inline or > not in that case depending on cost. I think it makes more sense to say > that we never inline if MATERIALIZED is specified, that we always inline > if NOT MATERIALIZED is specified, and that if neither is specified the > planner will choose (but perhaps note that currently it always chooses > only based on refcount). I have no objection to documenting it like that; I just don't want us to go off into the weeds trying to actually implement something smarter for v12. regards, tom lane