Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g8EAq-0001qf-1s for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Oct 2018 00:40:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g8EAn-0003zW-L6 for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Oct 2018 00:40:53 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g8EAC-0001HX-Tg for pgsql-hackers@lists.postgresql.org; Fri, 05 Oct 2018 00:40:17 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g8EA9-0005Xe-3m for pgsql-hackers@postgresql.org; Fri, 05 Oct 2018 00:40:15 +0000 Received: from [192.168.127.1] (port=41320 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1g8EA2-0007fz-CX; Fri, 05 Oct 2018 00:40:06 +0000 Received: from [127.0.0.1] (port=12496 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1g8EA1-000FY0-MF; Fri, 05 Oct 2018 00:40:05 +0000 From: Andrew Gierth To: Andreas Karlsson Cc: David Fetter , Thomas Munro , Pg Hackers Subject: Re: Early WIP/PoC for inlining CTEs In-Reply-To: <5bad579d-7a99-74de-2311-b4f049da8b40@proxel.se> (Andreas Karlsson's message of "Thu, 4 Oct 2018 11:22:32 +0200") Message-ID: <87y3bdckvu.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> <20181003155720.GG25294@fetter.org> <5bad579d-7a99-74de-2311-b4f049da8b40@proxel.se> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Fri, 05 Oct 2018 01:40:05 +0100 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Andreas" == Andreas Karlsson writes: > On 10/03/2018 05:57 PM, David Fetter wrote: >> Is there any meaningful distinction between "inlining," by which I >> mean converting to a subquery, and predicate pushdown, which >> would happen at least for a first cut, at the rewrite stage? Yes. Andreas> Sorry, but I do not think I understand your question. The Andreas> ability to push down predicates is just one of the potential Andreas> benefits from inlining. Consider the difference between (in the absence of CTE inlining): -- inline subquery with no optimization barrier (qual may be pushed down) select * from (select x from y) s where x=1; -- inline subquery with optimization barrier (qual not pushed down) select * from (select x from y offset 0) s where x=1; -- CTE with materialization with s as (select x from y) select * from s where x=1; -- Andrew (irc:RhodiumToad)