Leverage an open-source Foreign Data Wrapper (FDW) to query Snowflake tables directly from PostgreSQL.
Joining Snowflake facts with operational PostgreSQL tables in real time removes ETL lag and keeps analytics close to the app layer.
Use odbc_fdw
or the dedicated snowflake_fdw
. Both rely on Snowflake’s ODBC driver and are MIT-licensed.
1) Install Snowflake ODBC driver. 2) Compile and install the FDW. 3) CREATE EXTENSION in the target database. 4) CREATE SERVER and USER MAPPING.5) IMPORT FOREIGN SCHEMA or CREATE FOREIGN TABLES.
Run the syntax below, replacing connection details with your warehouse, database, role, user, and password.
After importing tables, prefix them with the foreign schema (e.g., snowflake.products
) and join them with local tables as usual.
Filter early. Only SELECT needed columns.Create statistics on foreign tables with ANALYZE
so the planner can estimate row counts.
The Snowflake user must have USAGE
on database & schema plus SELECT
on the target tables.PostgreSQL role needs USAGE
on the FDW server.
See the dedicated section below for quick resolutions.
Yes—enable OPTIONS (updatable 'true')
and grant INSERT/UPDATE/DELETE
on Snowflake tables.
Always qualify foreign tables (snowflake.orders
) or add the foreign schema to search_path
.
Push filters down with WHERE clauses; otherwise, large Snowflake tables will fully materialize in PostgreSQL.
Store credentials in ~/.odbc.ini
, limit warehouse auto-suspend to cut costs, and schedule ANALYZE
on foreign tables.
Yes—many teams run it in prod, but monitor query latency and Snowflake credits.
No.Only tables and views are accessible; stages require external integrations.
.
Yes, but monitor latency and credit consumption.
Yes—use OPTIONS (updatable 'true') and grant DML privileges.
Role selected in the SERVER definition applies to every session, so create separate servers for different roles.