【问题标题】:foreign data wrapper caching mechanism support外来数据封装缓存机制支持
【发布时间】:2017-03-20 22:16:17
【问题描述】:

我想使用 FDW 访问来自不同数据源(CSV、SQL Server、Web Server)的数据。我想知道Foreign表是否支持缓存机制,以便在连接丢失时数据仍然可用?

谢谢。

【问题讨论】:

  • 我可以从外部表创建物化视图还是仅用于本地表?
  • 当然。与本地表相同 - 只需定义 qry
  • 谢谢。我会试试这个:)

标签: postgresql caching foreign-data-wrapper


【解决方案1】:

使用MATERIALIZED VIEW的示例

t=# create foreign table ft1 (pid int,state text) server past options (schema_name 'pg_catalog',table_name 'pg_stat_activity');
CREATE FOREIGN TABLE
Time: 1.771 ms
t=# create materialized view mv1 as select * FROM ft1 where state = 'active';
SELECT 8
Time: 275.935 ms
t=# select * from mv1;
  pid  | state
-------+--------
 15103 | active
 17699 | active
   795 | active
 17211 | active
  3434 | active
 20671 | active
 20888 | active
 27827 | active
(8 rows)

Time: 0.289 ms
t=# refresh materialized view mv1;
REFRESH MATERIALIZED VIEW
Time: 329.095 ms
t=# select * from mv1;
  pid  | state
-------+--------
 15103 | active
 17699 | active
   795 | active
 17211 | active
  3434 | active
 27396 | active
 27780 | active
 27803 | active
(8 rows)

Time: 0.401 ms

【讨论】:

    猜你喜欢
    • 2020-07-21
    • 1970-01-01
    • 1970-01-01
    • 2011-08-24
    • 2015-11-30
    • 1970-01-01
    • 1970-01-01
    • 2011-09-27
    相关资源
    最近更新 更多