如何在一天结束后立即刷新物化视图
How to refresh a materialized view as soon as the day gets over in postgres
我正在从事一个项目,该项目要求我编写查询以在 postgres 中创建物化视图。我的要求是物化视图必须每天只在凌晨 12 点定期刷新。虽然我在网上找到了一些可能与其他地方相关的信息,但我不太确定是否要修改和实施,因为这对我来说可能成本太高,而且我在 sql 方面经验不足.
如文档所述:
https://www.postgresql.org/docs/current/sql-creatematerializedview.html
CREATE MATERIALIZED VIEW defines a materialized view of a query. The query is executed and used to populate the view at the time the command is issued (unless WITH NO DATA is used) and may be refreshed later using REFRESH MATERIALIZED VIEW.
因此,为了刷新实体化视图,您需要:
https://www.postgresql.org/docs/current/sql-refreshmaterializedview.html
REFRESH MATERIALIZED VIEW
为了定期执行此操作,您需要某种 cron 实施。
Postgresql "inhouse" 解决方案可以是:https://github.com/citusdata/pg_cron
我正在从事一个项目,该项目要求我编写查询以在 postgres 中创建物化视图。我的要求是物化视图必须每天只在凌晨 12 点定期刷新。虽然我在网上找到了一些可能与其他地方相关的信息,但我不太确定是否要修改和实施,因为这对我来说可能成本太高,而且我在 sql 方面经验不足.
如文档所述:
https://www.postgresql.org/docs/current/sql-creatematerializedview.html
CREATE MATERIALIZED VIEW defines a materialized view of a query. The query is executed and used to populate the view at the time the command is issued (unless WITH NO DATA is used) and may be refreshed later using REFRESH MATERIALIZED VIEW.
因此,为了刷新实体化视图,您需要:
https://www.postgresql.org/docs/current/sql-refreshmaterializedview.html
REFRESH MATERIALIZED VIEW
为了定期执行此操作,您需要某种 cron 实施。
Postgresql "inhouse" 解决方案可以是:https://github.com/citusdata/pg_cron