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 1j1tg0-0005yH-B0 for pgsql-bugs@arkaria.postgresql.org; Wed, 12 Feb 2020 15:11:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j1tfy-0003ig-WC for pgsql-bugs@arkaria.postgresql.org; Wed, 12 Feb 2020 15:11:42 +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 1j1tfy-0003iT-NY for pgsql-bugs@lists.postgresql.org; Wed, 12 Feb 2020 15:11:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j1tfw-0002LI-Gl for pgsql-bugs@lists.postgresql.org; Wed, 12 Feb 2020 15:11:42 +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 01CFBbZt023592; Wed, 12 Feb 2020 10:11:38 -0500 From: Tom Lane To: robfordww@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16255: No respect for 'not materialized' on CTEs with group by In-reply-to: <16255-e18a59c1ef606bbc@postgresql.org> References: <16255-e18a59c1ef606bbc@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Wed, 12 Feb 2020 12:28:25 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <23589.1581520297.1@sss.pgh.pa.us> Date: Wed, 12 Feb 2020 10:11:37 -0500 Message-ID: <23590.1581520297@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > I have an simple CTE expression with group by and a string_aggr() function, > and Postgresql seems to materialize it anyhow, even if 'not materialized' is > instructed. I can't see that this is documented behaviour. Since you haven't given a concrete example, nobody else can see whether it is either. But in general, there is no guarantee that "NOT MATERIALIZED" will do anything. There are multiple conditions that will prevent inlining a CTE, either for semantic or implementation reasons. regards, tom lane