pg_clickhouse
pg_clickhouse : Interfaces to query ClickHouse databases from PostgreSQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 2460 | pg_clickhouse
|
pg_clickhouse
|
0.1.10 |
OLAP
|
Apache-2.0
|
C++
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--sLd-r
|
No
|
Yes
|
Yes
|
Yes
|
yes
|
no
|
| Relationships | |
|---|---|
| See Also | pg_duckdb
duckdb_fdw
citus
columnar
citus_columnar
clickhouse_fdw
postgres_fdw
dblink
|
Release tag 0.1.10 still ships extension SQL version 0.1; source tarball vendors submodules.
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY
|
0.1.10 |
18
17
16
15
14
|
pg_clickhouse |
- |
| RPM | PIGSTY
|
0.1.10 |
18
17
16
15
14
|
pg_clickhouse_$v |
- |
| DEB | PIGSTY
|
0.1.10 |
18
17
16
15
14
|
postgresql-$v-clickhouse |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
el8.aarch64
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
el9.x86_64
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
el9.aarch64
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
el10.x86_64
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
el10.aarch64
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
d12.x86_64
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
d12.aarch64
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
d13.x86_64
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
d13.aarch64
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
u22.x86_64
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
u22.aarch64
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
u24.x86_64
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
u24.aarch64
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
PIGSTY 0.1.10
|
Source
pig build pkg pg_clickhouse; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install pg_clickhouse; # install via package name, for the active PG version
pig install pg_clickhouse -v 18; # install for PG 18
pig install pg_clickhouse -v 17; # install for PG 17
pig install pg_clickhouse -v 16; # install for PG 16
pig install pg_clickhouse -v 15; # install for PG 15
pig install pg_clickhouse -v 14; # install for PG 14Config this extension to shared_preload_libraries:
shared_preload_libraries = 'pg_clickhouse';Create this extension with:
CREATE EXTENSION pg_clickhouse;Usage
Syntax:
CREATE EXTENSION pg_clickhouse; CREATE SERVER taxi_srv FOREIGN DATA WRAPPER clickhouse_fdw OPTIONS(driver 'binary', host 'localhost', dbname 'taxi'); CREATE USER MAPPING FOR CURRENT_USER SERVER taxi_srv OPTIONS (user 'default'); IMPORT FOREIGN SCHEMA taxi FROM SERVER taxi_srv INTO taxi;
pg_clickhouse is a PostgreSQL extension for running analytics queries on ClickHouse directly from PostgreSQL, including a foreign data wrapper and query pushdown support. The current upstream docs state support for PostgreSQL 13+ and ClickHouse 23+.
Getting Started
The upstream project documents two common starting points:
- use the published Docker image
ghcr.io/clickhouse/pg_clickhouse:18 - build with
make/make installor install from PGXN
Once installed, enable the extension:
CREATE EXTENSION pg_clickhouse;Or install it into a dedicated schema:
CREATE SCHEMA ch;
CREATE EXTENSION pg_clickhouse WITH SCHEMA ch;Connecting to ClickHouse
The reference docs show the normal flow as:
CREATE SERVER taxi_srv
FOREIGN DATA WRAPPER clickhouse_fdw
OPTIONS (driver 'binary', host 'localhost', dbname 'taxi');
CREATE USER MAPPING FOR CURRENT_USER
SERVER taxi_srv
OPTIONS (user 'default');
CREATE SCHEMA taxi;
IMPORT FOREIGN SCHEMA taxi FROM SERVER taxi_srv INTO taxi;Documented server options include:
driver, required, eitherbinaryorhttpdbnamefetch_sizehostport
What the Docs Emphasize
The README positions pg_clickhouse around transparent pushdown for analytic workloads. It links both a tutorial and a SQL reference:
- the tutorial walks through connecting PostgreSQL to a ClickHouse sample database and querying imported tables
- the reference documents extension lifecycle commands, foreign server options, and SQL objects exposed by the extension
The project README also includes TPC-H benchmark examples showing where pushdown can significantly reduce runtime.
Operational Notes
The reference docs describe versioning separately for:
- the library version, visible via
pgch_version()orpg_get_loaded_modules() - the extension version tracked by PostgreSQL catalogs and extension upgrade scripts
Minor and major upgrades can require ALTER EXTENSION pg_clickhouse UPDATE.