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 1gcC9H-0006CC-CH for pgsql-general@arkaria.postgresql.org; Wed, 26 Dec 2018 16:35:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gcC9F-0006wl-VV for pgsql-general@arkaria.postgresql.org; Wed, 26 Dec 2018 16:35:09 +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 1gcC9F-0006wd-Nk for pgsql-general@lists.postgresql.org; Wed, 26 Dec 2018 16:35:09 +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 1gcC9D-0004mu-M3 for pgsql-general@lists.postgresql.org; Wed, 26 Dec 2018 16:35:09 +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 wBQGZ5LM029166; Wed, 26 Dec 2018 11:35:05 -0500 From: Tom Lane To: Mitar cc: pgsql-general@lists.postgresql.org Subject: Re: CREATE UNLOGGED MATERIALIZED VIEW In-reply-to: References: Comments: In-reply-to Mitar message dated "Tue, 25 Dec 2018 01:13:03 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <29164.1545842105.1@sss.pgh.pa.us> Date: Wed, 26 Dec 2018 11:35:05 -0500 Message-ID: <29165.1545842105@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Mitar writes: > I am looking at parser grammar rules and it looks like the following > is a valid query: > CREATE UNLOGGED MATERIALIZED VIEW > Any particular reason this is not documented? Because it's not supported: regression=# CREATE UNLOGGED MATERIALIZED VIEW foo AS select 1; ERROR: materialized views cannot be UNLOGGED Tracing down the source of that error message, we find /* * For now, we disallow unlogged materialized views, because it seems * like a bad idea for them to just go to empty after a crash. (If we * could mark them as unpopulated, that would be better, but that * requires catalog changes which crash recovery can't presently * handle.) */ if (stmt->into->rel->relpersistence == RELPERSISTENCE_UNLOGGED) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("materialized views cannot be UNLOGGED"))); So that's a value judgment you might or might not agree with (and even if you don't, it's not clear whether there are any deeper implementation problems that would be exposed if we just deleted this prohibition). But there it is, and it's why the documentation doesn't mention such a capability. The reason the grammar allows the possibility is likely some combination of (1) sharing grammar with other statements, (2) an error like the above is a lot more user-friendly than "syntax error" if someone tries to use the nonexistent feature, and (3) making provision for future enhancements. regards, tom lane