# A tour of Postgres' Foreign Data Wrappers

DevFeed: [A tour of Postgres' Foreign Data Wrappers](<https://devfeed.tech/articles/a-tour-of-postgres-foreign-data-wrappers-41190.md>)

Original publisher: [Read original article](<https://www.craigkerstiens.com/2016/09/11/a-tour-of-fdws/>)

Author: Map

Published: 2016-09-11T20:55:56Z

Content type: tutorial

Language: en

Sources: [Craig Kerstiens](<https://devfeed.tech/sources/craig-kerstiens.md>)

Topics: [SQL](<https://devfeed.tech/topics/sql.md>), [Databases](<https://devfeed.tech/topics/databases.md>), [etl](<https://devfeed.tech/topics/etl.md>), [MySQL](<https://devfeed.tech/topics/mysql.md>)

Tags: [database](<https://devfeed.tech/tags/database.md>), [mysql](<https://devfeed.tech/tags/mysql.md>), [pipeline](<https://devfeed.tech/tags/pipeline.md>), [postgres](<https://devfeed.tech/tags/postgres.md>), [sql](<https://devfeed.tech/tags/sql.md>), [sql-database](<https://devfeed.tech/tags/sql-database.md>)

## AI overview

A practical overview of PostgreSQL foreign data wrappers (FDWs), which connect PostgreSQL to remote systems and let users query or join that data from PostgreSQL. The article explains setup, capabilities, tradeoffs versus ETL, and briefly discusses PostgreSQL and MySQL FDWs.

## Source excerpt

SQL can be a powerful language for reporting. Whether you're just exploring some data, or generating reports that show month over month revenue growth it's the lingua franca for data analysis. But, your data isn't always in a SQL database, even then if you're using Postgres you can still likely use SQL to analyze, query, even joing with that data. Foreign data wrappers have been around for years in Postgres, but are continuing to mature and be a great option for joining disparate systems. Overview of foreign data wrappers If you're unfamiliar, foreign data wrappers, or FDW, allow you to connect from within Postgres to a remote system. Then you can query them from directly within Postgres. While there is an official Postgres FDW that ships with Postgres itself, that allows you to connect from one Postgres DB to another, there's also a broad community of others. At the core of it Postgres provides certain APIs under the covers which each FDW extension can implement. This can include the ability to map SQL to whatever makes sense for a given system, push down various operators like where clauses, and as of Postgres 9.3 can even write data. To setup a FDW you first would install the extension, then provide the connection to the remote system, setup your schema/tables, and then you're off to the races-or well ready to query. If you've got more than 2-3 databases or systems in your infrastructure, you'll often benefit from FDWs as opposed to introducing a heavyweight ETL pipeline. Don't mistake FDWs as the most performant method for joining data, but they are often the developer time efficient means of joining these data sets. Let's look at just a few of the more popular and interesting ones. Postgres FDW The Postgres one is the easiest to get started with. First you'll just enable it with CREATE EXTENSION, then you'll setup your remote server: CREATE EXTENSION postgres_fdw; CREATE SERVER core_db FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'foo', dbname 'core_db', por