Skip to content
pg_clickhouse

pg_clickhouse

pg_clickhouse : Interfaces to query ClickHouse databases from PostgreSQL

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
2460
pg_clickhouse
pg_clickhouse
0.2.0
OLAP
Apache-2.0
C++
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--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 0.2.0; SQL v0.2

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PIGSTY
0.2.0
18
17
16
15
14
pg_clickhouse-
RPM
PIGSTY
0.2.0
18
17
16
15
14
pg_clickhouse_$v-
DEB
PIGSTY
0.2.0
18
17
16
15
14
postgresql-$v-clickhouse-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
el8.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
el9.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
el9.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
el10.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
el10.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
d12.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
d12.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
d13.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
d13.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
u22.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
u22.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
u24.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
u24.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
u26.x86_64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
u26.aarch64
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PIGSTY 0.2.0
PackageVersionOSORGSIZEFile URL
pg_clickhouse_180.2.0el8.x86_64pigsty724.2 KiBpg_clickhouse_18-0.2.0-1PIGSTY.el8.x86_64.rpm
pg_clickhouse_180.2.0el8.aarch64pigsty645.0 KiBpg_clickhouse_18-0.2.0-1PIGSTY.el8.aarch64.rpm
pg_clickhouse_180.2.0el9.x86_64pigsty729.8 KiBpg_clickhouse_18-0.2.0-1PIGSTY.el9.x86_64.rpm
pg_clickhouse_180.2.0el9.aarch64pigsty699.4 KiBpg_clickhouse_18-0.2.0-1PIGSTY.el9.aarch64.rpm
pg_clickhouse_180.2.0el10.x86_64pigsty753.2 KiBpg_clickhouse_18-0.2.0-1PIGSTY.el10.x86_64.rpm
pg_clickhouse_180.2.0el10.aarch64pigsty717.0 KiBpg_clickhouse_18-0.2.0-1PIGSTY.el10.aarch64.rpm
postgresql-18-clickhouse0.2.0d12.x86_64pigsty859.5 KiBpostgresql-18-clickhouse_0.2.0-1PIGSTY~bookworm_amd64.deb
postgresql-18-clickhouse0.2.0d12.aarch64pigsty796.3 KiBpostgresql-18-clickhouse_0.2.0-1PIGSTY~bookworm_arm64.deb
postgresql-18-clickhouse0.2.0d13.x86_64pigsty863.3 KiBpostgresql-18-clickhouse_0.2.0-1PIGSTY~trixie_amd64.deb
postgresql-18-clickhouse0.2.0d13.aarch64pigsty801.1 KiBpostgresql-18-clickhouse_0.2.0-1PIGSTY~trixie_arm64.deb
postgresql-18-clickhouse0.2.0u22.x86_64pigsty927.8 KiBpostgresql-18-clickhouse_0.2.0-1PIGSTY~jammy_amd64.deb
postgresql-18-clickhouse0.2.0u22.aarch64pigsty900.1 KiBpostgresql-18-clickhouse_0.2.0-1PIGSTY~jammy_arm64.deb
postgresql-18-clickhouse0.2.0u24.x86_64pigsty939.7 KiBpostgresql-18-clickhouse_0.2.0-1PIGSTY~noble_amd64.deb
postgresql-18-clickhouse0.2.0u24.aarch64pigsty906.6 KiBpostgresql-18-clickhouse_0.2.0-1PIGSTY~noble_arm64.deb
postgresql-18-clickhouse0.2.0u26.x86_64pigsty934.5 KiBpostgresql-18-clickhouse_0.2.0-1PIGSTY~resolute_amd64.deb
postgresql-18-clickhouse0.2.0u26.aarch64pigsty951.2 KiBpostgresql-18-clickhouse_0.2.0-1PIGSTY~resolute_arm64.deb

Source

pig build pkg pg_clickhouse;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install 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 14

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pg_clickhouse';

Create this extension with:

CREATE EXTENSION pg_clickhouse;

Usage

Sources: README, reference, tutorial, v0.2.0 release notes

pg_clickhouse runs analytics queries on ClickHouse from PostgreSQL through the clickhouse_fdw foreign data wrapper. Upstream documents PostgreSQL 13+ and ClickHouse 23+ support.

Connect PostgreSQL to ClickHouse

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');

CREATE SCHEMA taxi;
IMPORT FOREIGN SCHEMA taxi FROM SERVER taxi_srv INTO taxi;

Server options documented upstream:

  • driver: required, binary or http
  • host
  • port
  • dbname
  • fetch_size: HTTP streaming batch size; 0 disables streaming

User mapping options:

  • user
  • password

Common operations

ALTER EXTENSION pg_clickhouse UPDATE;
ALTER EXTENSION pg_clickhouse UPDATE TO '0.2';
DROP SERVER taxi_srv CASCADE;

IMPORT FOREIGN SCHEMA also supports LIMIT TO (...) and EXCEPT (...). The reference warns that imported mixed-case identifiers are double-quoted in PostgreSQL and must be queried with quotes.

Version and pushdown notes

  • The reference documents separate library and extension versions; pgch_version() was added in release v0.2.0.
  • Patch-only releases update the library without requiring ALTER EXTENSION.
  • Release v0.2.0 added more pushdown for arrays, regex functions, split_part(), array operators, and current date/time expressions, plus the pg_clickhouse.pushdown_regex setting.

Caveats

  • This is positioned upstream as an analytics-first extension; the roadmap still lists broader DML support as future work.
  • For full examples, follow the official tutorial, which creates a ClickHouse taxi database, imports it through IMPORT FOREIGN SCHEMA, and queries the resulting foreign tables.
Last updated on