How it works...
In this recipe, we begin by moving the existing pgbench_accounts table out of the way. The intent, in this case, is to prove that we can treat a materialized view in a similar way to a local table. To do this, we want to create it with the same name that the foreign table currently uses. This means that pgbench_accounts becomes remote_accounts and better illustrates its relationship with the foreign server as a bonus.
Next, we create the actual materialized view. We could define all of the columns manually, but in this case, we want it to simply mirror the remote table. Think of this as object-oriented programming: we have a class named pgbench_remote, and we will instantiate it as pgbench_accounts.
Note, however, that we ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access