【问题标题】:Fetch last Refresh time of Materialized View in CockroachDB获取 CockroachDB 中物化视图的最后刷新时间
【发布时间】:2021-03-30 04:09:50
【问题描述】:

在 CockroachDB v20.2 中,可以使用以下方法检索Materialized Views 的列表:

> SELECT * FROM pg_catalog.pg_matviews;
  schemaname | matviewname | matviewowner | tablespace | hasindexes | ispopulated | definition
----------------------------------------------------------------------------------------------------
  public     | VIEWNAME    | root         | NULL       |   false    |    true     | VIEWDEFINITION

从这里,我们怎样才能找到这个视图的最后一个时间Refreshed

【问题讨论】:

    标签: sql materialized-views cockroachdb


    【解决方案1】:

    据我所知,这些信息不能从内部表中获得。我认为 PostgreSQL 也没有。

    一种解决方法可能是使用额外的时间戳列定义您的物化视图,例如:

    create materialized view my_view as select col, now() as last_updated from tab;
    

    这样做的缺点是视图中的每一行都会有这一列,并且会使用额外的磁盘空间。

    【讨论】:

      猜你喜欢
      • 2010-09-27
      • 2011-08-13
      • 1970-01-01
      • 2014-02-05
      • 2011-07-09
      • 2013-12-04
      • 1970-01-01
      • 1970-01-01
      • 2015-05-27
      相关资源
      最近更新 更多