从 Postgres 中的另一个物化视图调用物化视图

Calling a materialized view from another materialized view in Postgres

是否可以创建一个名为 first_view 的视图,并在另一个名为 second_view 的视图中创建第一个叫什么? This is the original question.

这是第一个视图:

CREATE MATERIALIZED VIEW first_view
AS SELECT atable.variable_one, btable.another_variable, ctable.variable_x
FROM a atable, b btable, c ctable

因此可以在 f(ALL) 中调用 f(a,b,c) 视图,即 f(a,b,c) 包括具有聚合函数的 f(m)。

答案很简单,我认为我没有正确理解你的问题:

只需像使用任何其他 table 或在第二个 MVIEW 中查看一样使用第一个 MVIEW:

create materialized view first_view
as
select a.column_one, b.column_two, c.column_three
from table_a a 
   join table_b b on a.id = b.aid
   join table_c c on b.id = c.bid;

create materialized view second_view
as
select x.some_column, f.*
from other_table x
   join first_view f on x.id = f.column_one;