You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
createdatabasemyforeign1;
\c myforeign1
createtableusers (id serialprimary key, email varchar);
insert into users (email) values ('agnes.larson@test.com'),('aayan.garrison@test3.com');
createdatabasemyforeign2;
\c myforeign2
createtableusers (id serialprimary key, email varchar);
insert into users (email) values ('zaynab.ray@test2.com'),('hajra.escobar@test.com');
install the extension one time
\c manifest
create extension postgres_fdw;
run on manifest db upon each new cloud instance creation
create server foreign_server1
foreign data wrapper postgres_fdw
options (host 'localhost', port '5432', dbname 'myforeign1');
create server foreign_server2
foreign data wrapper postgres_fdw
options (host 'localhost', port '5432', dbname 'myforeign2');
createusermapping for mmuser
server foreign_server1
options (user 'mmuser', password 'test123');
createusermapping for mmuser
server foreign_server2
options (user 'mmuser', password 'test123');
create foreign table foreign_users_table1 (
id serial,
email varchar
)
server foreign_server1
options (schema_name 'public', table_name 'users');
create foreign table foreign_users_table2 (
id serial,
email varchar
)
server foreign_server2
options (schema_name 'public', table_name 'users');
create materialized view mat_view asselect'instance1'as instance, email from foreign_users_table1
union allselect'instance2'as instance, email from foreign_users_table2;
run on each new user and invite created, updated, deleted on all instances
refresh materialized view mat_view;
lookup instances associated to email
select instance from mat_view where email ='agnes.larson@test.com';