I am wondering how foreign data in Postgres are updated. I understand that the FDW makes a connection to the remote database to access the tables, and the foreign tables don't take up physical memory in the database. It is the equivalent of making a select statement to the the underlying tables.
I have some tables in Database A that I have imported as foreign tables into database B. I am using the foreign Tables in Database B to create materialized views. I am running these commands in Database B:
IMPORT FOREIGN SCHEMA completed LIMIT TO (tb1,tbl2)
FROM SERVER db_data_pipeline
INTO public;
COMMIT;
CREATE MV1 AS SELECT * FROM TB1;
My tables in database A are updated through a drop and recreate process. I have two questions regarding how foreign data are synchronized:
Since my tables in database A are updated through a drop and recreate, are the foreign tables in Database B also updated automatically? is there a scenario where the foreign data becomes 'stale'? Would I have to re-import foreign tables to keep them up to date?
I've read that the foreign table definition does not change when the underlying table changes. For example, a column added in the underlying table will not be reflected in the foreign table. However, since my underlying table is never updated directly and dropped and recreated instead, do I have to worry about this issue?