2 Comments
User's avatar
lakshmikanth p's avatar

This is an interesting topic and may i know if the data access frameworks included this in their libraries or frameworks?

Would love to test it out in our typescript backend system.

Expand full comment
Julien Singler's avatar

Great question! PostgreSQL FDW is a server-side extension: once you've set it up on your database, any data access framework (like Prisma, TypeORM, Sequelize, or even plain pg) will see the foreign tables as if they were regular tables. You can query and manipulate them using standard SQL, and your TypeScript backend doesn't need any special code to use FDW—just connect to PostgreSQL as usual and reference the foreign tables by name.

Most frameworks don't have explicit "FDW" features because, from the application's point of view, there's no difference between a local and a foreign table. Just keep in mind that some advanced FDW features (like pushdown of complex queries or write support) depend on the specific FDW extension and its configuration in PostgreSQL.

In this article I created the foreign tables in a separate schema ("foreign_schema") instead of creating them into the usual "public" schema, however, you could create foreign tables directly in "public".

So, you can absolutely test this in your TypeScript backend: set up FDW on your database, import the foreign schema, and then use your usual queries or ORM models to access the data. Everything else "just works" from the application side.

Expand full comment