Обсуждение: Example on difference between CREATE MATERIALIZED VIEW and standard VIEW has typo

Поиск
Список
Период
Сортировка

Example on difference between CREATE MATERIALIZED VIEW and standard VIEW has typo

От
PG Doc comments form
Дата:
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/17/rules-materializedviews.html
Description:

Unless I'm completely mistaken, the second code example on
https://www.postgresql.org/docs/current/rules-materializedviews.html, i.e
this:

CREATE TABLE mymatview AS SELECT * FROM mytab;

Should instead by

CREATE VIEW mymatview AS SELECT * FROM mytab;

(I.e, create a VIEW, not a TABLE).

Could also be debated if the view name should be the same in both examples.
I.e the second example might be even better as below:

CREATE VIEW myview AS SELECT * from mytab;

Re: Example on difference between CREATE MATERIALIZED VIEW and standard VIEW has typo

От
"David G. Johnston"
Дата:
On Fri, Aug 22, 2025 at 2:23 PM PG Doc comments form <noreply@postgresql.org> wrote:
Unless I'm completely mistaken, the second code example on
https://www.postgresql.org/docs/current/rules-materializedviews.html, i.e
this:

CREATE TABLE mymatview AS SELECT * FROM mytab;

Should instead by

CREATE VIEW mymatview AS SELECT * FROM mytab;

No, the example's intent is to compare a true "materialized view" with a table that is simply populated from a query.  The comment "the materialized view cannot subsequently be directly updated" only makes sense as a counterpoint to a physical table.

David J.

Re: Example on difference between CREATE MATERIALIZED VIEW and standard VIEW has typo

От
"Erik Forsberg"
Дата:
On Fri, Aug 22, 2025, at 23:40, David G. Johnston wrote:
On Fri, Aug 22, 2025 at 2:23 PM PG Doc comments form <noreply@postgresql.org> wrote:
Unless I'm completely mistaken, the second code example on
this:

CREATE TABLE mymatview AS SELECT * FROM mytab;

Should instead by

CREATE VIEW mymatview AS SELECT * FROM mytab;

No, the example's intent is to compare a true "materialized view" with a table that is simply populated from a query.  The comment "the materialized view cannot subsequently be directly updated" only makes sense as a counterpoint to a physical table.

David J.


Right, I stand corrected, and realize I don't know enough about standard view.

Maybe its the naming of the example *table* with the suffix *view* that completely mess up my brain, but I guess given the intent that's how it should be.

Thanks,
Erik

Re: Example on difference between CREATE MATERIALIZED VIEW and standard VIEW has typo

От
Wim Bertels
Дата:
Hello,

that is just the point:

cf
"
are that the materialized view cannot subsequently be directly updated
and that the query used to create the materialized view is stored in
exactly the same way that a view's query is stored, so that fresh data
can be generated for the materialized view with:
"

although that the wording might be better? (non-native speaker)

"
the content of both objects is the same, but the content of the table
is not linked to the query, whereas the materialized view does have
this information of that query, so that fresh data can be generated for
the materialized view without explicitly specifying the query that was
used to generate the object
"

mvg,
Wim

PG Doc comments form schreef op do 21-08-2025 om 14:07 [+0000]:
> The following documentation comment has been logged on the website:
>
> Page:
> https://www.postgresql.org/docs/17/rules-materializedviews.html
> Description:
>
> Unless I'm completely mistaken, the second code example on
> https://www.postgresql.org/docs/current/rules-materializedviews.html
> , i.e
> this:
>
> CREATE TABLE mymatview AS SELECT * FROM mytab;
>
> Should instead by
>
> CREATE VIEW mymatview AS SELECT * FROM mytab;
>
> (I.e, create a VIEW, not a TABLE).
>
> Could also be debated if the view name should be the same in both
> examples.
> I.e the second example might be even better as below:
>
> CREATE VIEW myview AS SELECT * from mytab;