在 postgresql 中使用视图来启用支持表的透明替换
Using views in postgresql to enable transparent replacement of backing tables
我们有一个从支持 table 聚合的观点。这个想法是通过使用预先聚合的 table 来减少 cpu 负载,并使用以下内容定期刷新它:
- 创建new_backing_table(填充)
- 开始
- 放弃支持table
- 将 new_backingtable 重命名为 backingtable
- 提交
在制作中。刷新间隔导致的延迟是acceptable。增量更新是可能的,但不可取。
有人对这个方案有意见吗?
检查物化视图。这可能适合您的用例。它可用于在创建时存储查询结果,然后在稍后刷新。
A materialized view is defined as a table which is actually physically stored on disk, but is really just a view of other database tables. In PostgreSQL, like many database systems, when data is retrieved from a traditional view it is really executing the underlying query or queries that build that view.
https://www.postgresql.org/docs/9.3/static/sql-creatematerializedview.html
我们有一个从支持 table 聚合的观点。这个想法是通过使用预先聚合的 table 来减少 cpu 负载,并使用以下内容定期刷新它:
- 创建new_backing_table(填充)
- 开始
- 放弃支持table
- 将 new_backingtable 重命名为 backingtable
- 提交
在制作中。刷新间隔导致的延迟是acceptable。增量更新是可能的,但不可取。
有人对这个方案有意见吗?
检查物化视图。这可能适合您的用例。它可用于在创建时存储查询结果,然后在稍后刷新。
A materialized view is defined as a table which is actually physically stored on disk, but is really just a view of other database tables. In PostgreSQL, like many database systems, when data is retrieved from a traditional view it is really executing the underlying query or queries that build that view.
https://www.postgresql.org/docs/9.3/static/sql-creatematerializedview.html