After an update of Postgres from 9.6 to 14, accessing foreign tables in queries has become dramatically slower. The creation of materialized views based on foreign tables for example, may not terminate in 24 hours whereas it used to take a few minutes on 9.6.
I create foreign data wrapper like this:
CREATE SERVER myserver
FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (dbname 'mydb', host 'myhost', port '5432', fetch_size '100000', async_capable 'true');
and foreign tables like this:
IMPORT FOREIGN SCHEMA myforeignschema
FROM SERVER myserver INTO mylocalschema;
Is there anything else I can do to increase speed or to detect the cause of the slowdown?