Use an open-source foreign data wrapper (FDW) to query Amazon Redshift directly from PostgreSQL.
Querying Redshift from PostgreSQL eliminates ETL lag, lets developers join Redshift data with local tables, and keeps analytics in one place.
Most teams adopt the postgres_fdw
or community odbc_fdw
.Both are free, maintained, and installable via CREATE EXTENSION
.
Install the OS package (e.g., apt-get install postgresql-15-odbc-fdw
) or compile from GitHub, then run CREATE EXTENSION
in your database.
A superuser or a role with CREATE
privilege on the current database can create the server and user mapping. The Redshift user needs read access on target schemas.
Use IMPORT FOREIGN SCHEMA
for dozens of tables.For a hand-picked subset, manually write CREATE FOREIGN TABLE
definitions to control column names and data types.
Set FDW
keep_connections
to on
to avoid reconnect overhead and throttle limits on Redshift.
Add filters in the SELECT statement so the FDW sends them to Redshift, reducing data movement.
.
Yes, credentials live in CREATE USER MAPPING
. Combine with SSL and Redshift IAM users for principle-of-least-privilege.
Absolutely. Point the host to the generated Redshift Serverless endpoint; the FDW treats it like a regular cluster.
Most FDWs are read-only by default. Some support INSERT
/UPDATE
, but performance is limited. Use Redshift’s native COPY
for large loads.