外部数据包装器缓存机制支持
foreign data wrapper caching mechanism support
我想使用 FDW 访问来自不同数据源(CSV、SQL 服务器、Web 服务器)的数据。我想知道外部表是否支持缓存机制,以便在连接丢失时数据仍然可用?
谢谢。
示例使用 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
我想使用 FDW 访问来自不同数据源(CSV、SQL 服务器、Web 服务器)的数据。我想知道外部表是否支持缓存机制,以便在连接丢失时数据仍然可用?
谢谢。
示例使用 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