Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VkKYd-0008SR-13 for pgsql-bugs@arkaria.postgresql.org; Sat, 23 Nov 2013 21:16:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VkKYc-0003aI-CH for pgsql-bugs@arkaria.postgresql.org; Sat, 23 Nov 2013 21:16:02 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VkKYb-0003aB-Am for pgsql-bugs@postgresql.org; Sat, 23 Nov 2013 21:16:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VkKYZ-0001ay-AG for pgsql-bugs@postgresql.org; Sat, 23 Nov 2013 21:16:00 +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 rANLFpUI021661; Sat, 23 Nov 2013 16:15:51 -0500 From: Tom Lane To: Kevin Grittner cc: "j.rejda@konektel.cz" , "pgsql-bugs@postgresql.org" Subject: Re: BUG #8606: Materialized View WITH NO DATA bug In-reply-to: <1384956300.76210.YahooMailNeo@web162903.mail.bf1.yahoo.com> References: <1384901179.77177.YahooMailNeo@web162905.mail.bf1.yahoo.com> <31136.1384919378@sss.pgh.pa.us> <1384956300.76210.YahooMailNeo@web162903.mail.bf1.yahoo.com> Comments: In-reply-to Kevin Grittner message dated "Wed, 20 Nov 2013 06:05:00 -0800" Date: Sat, 23 Nov 2013 16:15:51 -0500 Message-ID: <21660.1385241351@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Kevin Grittner writes: > Tom Lane wrote: >> But having said that, it seems that this complaint implies that >> CREATE MATERIALIZED VIEW ... WITH NO DATA still runs the query >> through a planning cycle. Why is that? I can't immediately see >> any benefit to doing so. > Well, to be honest, it's because CREATE TABLE AS ... WITH NO DATA > does so, and I figured that if it was needed there I didn't see why > CREATE MATERIALIZED VIEW AS ... WITH NO DATA would be any > different. I'm shameless in copying what seems to be working. I looked at that a bit. The reason we have to plan, in the current code, is that we create the target table using column type info from the output tupdesc supplied by the executor; so we have to have a plan to fire up the executor on, even if we aren't going to fetch any data from the plan. It's conceivable that we could extract result type info directly from the original query (a la DefineVirtualRelation), but it'd be a significant amount of work and it would mean that the WITH DATA and WITH NO DATA code paths would be almost completely disjoint. Worse, we'd still need something pretty close to what we've got now to handle the CREATE TABLE AS ... EXECUTE case, making that probably a third totally separate path. So I'm thinking it's not worth the trouble to avoid a planning cycle here. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs