CREATE EXTENSION postgres_fdw; DO $d$ BEGIN EXECUTE $$CREATE SERVER loopback FOREIGN DATA WRAPPER postgres_fdw OPTIONS (dbname '$$||current_database()||$$', port '$$||current_setting('port')||$$' )$$; END; $d$; CREATE SERVER loopback FOREIGN DATA WRAPPER postgres_fdw OPTIONS (port '5432', dbname 'postgres'); CREATE USER MAPPING FOR CURRENT_USER SERVER loopback; CREATE TABLE format_fdw_parent (c1 int) PARTITION BY RANGE (c1); CREATE TABLE local_fdw_0_10 PARTITION OF format_fdw_parent FOR VALUES FROM (0) TO (10); CREATE TABLE foreign_fdw_10_20_remote (c1 int); create foreign table foreign_fdw_10_20 partition of format_fdw_parent FOR VALUES FROM (10) TO (20) server loopback options (table_name 'foreign_fdw_10_20_remote'); explain select * from format_fdw_parent; explain (analyze true, format json) select * from format_fdw_parent;