pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedCREATE UNLOGGED MATERIALIZED VIEW
7+ messages / 3 participants
[nested] [flat]
* CREATE UNLOGGED MATERIALIZED VIEW
@ 2018-12-25 09:13 Mitar <mmitar@gmail.com>
0 siblings, 2 replies; 7+ messages in thread
From: Mitar @ 2018-12-25 09:13 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi!
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?
Mitar
--
http://mitar.tnode.com/
https://twitter.com/mitar_m
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: CREATE UNLOGGED MATERIALIZED VIEW
@ 2018-12-25 18:14 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Mitar <mmitar@gmail.com>
1 sibling, 1 reply; 7+ messages in thread
From: Adrian Klaver @ 2018-12-25 18:14 UTC (permalink / raw)
To: Mitar <mmitar@gmail.com>; pgsql-general@lists.postgresql.org
On 12/25/18 1:13 AM, Mitar wrote:
> Hi!
>
> 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?
My guess because of this:
https://doxygen.postgresql.org/matview_8c.html
Line 458-461
"/*
* We can skip WAL-logging the insertions, unless PITR or streaming
* replication is in use. We can skip the FSM in any case.
*/
"
>
>
> Mitar
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: CREATE UNLOGGED MATERIALIZED VIEW
@ 2018-12-25 18:16 Mitar <mmitar@gmail.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 7+ messages in thread
From: Mitar @ 2018-12-25 18:16 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: pgsql-general@lists.postgresql.org
Hi!
That is for transient tables (NEW and OLD tables), no? Not for the
main materialized view table.
Mitar
On Tue, Dec 25, 2018 at 10:14 AM Adrian Klaver
<adrian.klaver@aklaver.com> wrote:
>
> On 12/25/18 1:13 AM, Mitar wrote:
> > Hi!
> >
> > 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?
>
> My guess because of this:
>
> https://doxygen.postgresql.org/matview_8c.html
>
> Line 458-461
>
> "/*
> * We can skip WAL-logging the insertions, unless PITR or streaming
> * replication is in use. We can skip the FSM in any case.
> */
> "
>
> >
> >
> > Mitar
> >
>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
--
http://mitar.tnode.com/
https://twitter.com/mitar_m
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: CREATE UNLOGGED MATERIALIZED VIEW
@ 2018-12-25 18:25 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Mitar <mmitar@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Adrian Klaver @ 2018-12-25 18:25 UTC (permalink / raw)
To: Mitar <mmitar@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
On 12/25/18 10:16 AM, Mitar wrote:
> Hi!
>
> That is for transient tables (NEW and OLD tables), no? Not for the
> main materialized view table.
Don't know. From my POV MATERIALIZED VIEWS are transient any way you
look at them. They capture a state at a point in time and then the data
they depend on moves on. Given that they can be refreshed at will not
sure logging/not logging really matters.
>
>
> Mitar
>
> On Tue, Dec 25, 2018 at 10:14 AM Adrian Klaver
> <adrian.klaver@aklaver.com> wrote:
>>
>> On 12/25/18 1:13 AM, Mitar wrote:
>>> Hi!
>>>
>>> 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?
>>
>> My guess because of this:
>>
>> https://doxygen.postgresql.org/matview_8c.html
>>
>> Line 458-461
>>
>> "/*
>> * We can skip WAL-logging the insertions, unless PITR or streaming
>> * replication is in use. We can skip the FSM in any case.
>> */
>> "
>>
>>>
>>>
>>> Mitar
>>>
>>
>>
>> --
>> Adrian Klaver
>> adrian.klaver@aklaver.com
>
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: CREATE UNLOGGED MATERIALIZED VIEW
@ 2018-12-25 18:29 Mitar <mmitar@gmail.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 0 replies; 7+ messages in thread
From: Mitar @ 2018-12-25 18:29 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: pgsql-general@lists.postgresql.org
Hi!
On Tue, Dec 25, 2018 at 10:25 AM Adrian Klaver
<adrian.klaver@aklaver.com> wrote:
> Don't know. From my POV MATERIALIZED VIEWS are transient any way you
> look at them. They capture a state at a point in time and then the data
> they depend on moves on. Given that they can be refreshed at will not
> sure logging/not logging really matters.
I agree with you. But current default is RELPERSISTENCE_PERMANENT. So
there is an option for RELPERSISTENCE_UNLOGGED.
So, I think that we should or a) make RELPERSISTENCE_UNLOGGED default,
b) document RELPERSISTENCE_UNLOGGED or c) remove it.
I propose b).
Mitar
--
http://mitar.tnode.com/
https://twitter.com/mitar_m
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: CREATE UNLOGGED MATERIALIZED VIEW
@ 2018-12-26 16:35 Tom Lane <tgl@sss.pgh.pa.us>
parent: Mitar <mmitar@gmail.com>
1 sibling, 1 reply; 7+ messages in thread
From: Tom Lane @ 2018-12-26 16:35 UTC (permalink / raw)
To: Mitar <mmitar@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
Mitar <mmitar@gmail.com> 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
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: CREATE UNLOGGED MATERIALIZED VIEW
@ 2018-12-27 09:13 Mitar <mmitar@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 7+ messages in thread
From: Mitar @ 2018-12-27 09:13 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general@lists.postgresql.org
Hi!
FYI, I started working on also adding TEMPORARY materialized views. [1]
[1] https://www.postgresql.org/message-id/CAKLmikOwqJx7J%3Dfg7VFcuk2OUjqLy%3DHZj_J5stY1x8X7%2B14g5g%40ma...
UNLOGGED is still unsupported, but TEMPORARY materialized views do not
have the issue mentioned in the comment above because they do not exit
after the crash anyway.
Mitar
On Wed, Dec 26, 2018 at 8:35 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Mitar <mmitar@gmail.com> 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
--
http://mitar.tnode.com/
https://twitter.com/mitar_m
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2018-12-27 09:13 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-12-25 09:13 CREATE UNLOGGED MATERIALIZED VIEW Mitar <mmitar@gmail.com>
2018-12-25 18:14 ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-12-25 18:16 ` Mitar <mmitar@gmail.com>
2018-12-25 18:25 ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-12-25 18:29 ` Mitar <mmitar@gmail.com>
2018-12-26 16:35 ` Tom Lane <tgl@sss.pgh.pa.us>
2018-12-27 09:13 ` Mitar <mmitar@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox