Access ClickHouse tables directly from PostgreSQL using the clickhouse_fdw foreign data wrapper.
Combine high-speed ClickHouse analytics with PostgreSQL joins, views, and constraints without moving data.
Install clickhouse_fdw
on the PostgreSQL server and create a ClickHouse user with read permissions.
Use CREATE SERVER
to register ClickHouse connection details such as host, port, and authentication.
Run IMPORT FOREIGN SCHEMA
or individual CREATE FOREIGN TABLE
statements to expose ClickHouse tables.
Yes.Once foreign tables exist, standard SQL joins work, allowing blended analytics across systems.
Explicitly cast ClickHouse Decimal
, DateTime64
, and Nullable
columns to matching PostgreSQL types to avoid runtime errors.
Use role-based privileges in PostgreSQL (GRANT SELECT
) and limit ClickHouse user scope to read-only.
Enable EXPLAIN (VERBOSE)
to verify pushdown.Large aggregations remain in ClickHouse, reducing network traffic.
Avoid write-heavy workloads or millisecond-latency OLTP queries; the FDW adds overhead over direct ClickHouse access.
.
Yes, many companies run it in production, but test complex queries and monitor pushdown plans.
The FDW pushes most WHERE, GROUP BY, and aggregate functions. Check with EXPLAIN to confirm.
Yes, pass secure
options in the SERVER definition, or tunnel through stunnel/SSL proxies.