pg_clickhouse

Interfaces to query ClickHouse databases from PostgreSQL

Overview

PackageVersionCategoryLicenseLanguage
pg_clickhouse0.1.4OLAPApache-2.0C++
IDExtensionBinLibLoadCreateTrustRelocSchema
2460pg_clickhouseNoYesNoYesNoNo-
Relatedpg_duckdb duckdb_fdw citus columnar citus_columnar clickhouse_fdw postgres_fdw dblink

with submodule

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY0.1.41817161514pg_clickhouse-
RPMPIGSTY0.1.41817161514pg_clickhouse_$v-
DEBPIGSTY0.1.41817161514postgresql-$v-clickhouse-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
d13.aarch64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
u22.x86_64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
u22.aarch64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
u24.x86_64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
u24.aarch64
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4
PIGSTY 0.1.4

Build

You can build the RPM / DEB packages for pg_clickhouse using pig build:

pig build pkg pg_clickhouse         # build RPM / DEB packages

Install

You can install pg_clickhouse directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

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

Install the extension using pig or apt/yum/dnf:

pig install pg_clickhouse;          # Install for current active PG version
pig ext install -y pg_clickhouse -v 18  # PG 18
pig ext install -y pg_clickhouse -v 17  # PG 17
pig ext install -y pg_clickhouse -v 16  # PG 16
pig ext install -y pg_clickhouse -v 15  # PG 15
pig ext install -y pg_clickhouse -v 14  # PG 14
dnf install -y pg_clickhouse_18       # PG 18
dnf install -y pg_clickhouse_17       # PG 17
dnf install -y pg_clickhouse_16       # PG 16
dnf install -y pg_clickhouse_15       # PG 15
dnf install -y pg_clickhouse_14       # PG 14
apt install -y postgresql-18-clickhouse   # PG 18
apt install -y postgresql-17-clickhouse   # PG 17
apt install -y postgresql-16-clickhouse   # PG 16
apt install -y postgresql-15-clickhouse   # PG 15
apt install -y postgresql-14-clickhouse   # PG 14

Create Extension:

CREATE EXTENSION pg_clickhouse;

Usage

pg_clickhouse: ClickHouse integration for PostgreSQL

pg_clickhouse enables analytics queries on ClickHouse directly from PostgreSQL without SQL rewriting. It supports PostgreSQL 13+ and ClickHouse v23+.

Create the Extension

CREATE EXTENSION pg_clickhouse;

Or into a specific schema:

CREATE SCHEMA env;
CREATE EXTENSION pg_clickhouse SCHEMA env;

Query Pushdown

The extension automatically pushes down analytical queries to ClickHouse for execution, providing significant performance improvements. For example, TPC-H benchmarks show:

  • Query 1: 268ms (vs 4,693ms on standard PostgreSQL)
  • Query 6: 53ms (vs 764ms on standard PostgreSQL)

When query pushdown is active, ClickHouse handles execution directly, avoiding data transfer overhead for complex analytical workloads.


Last Modified 2026-03-12: add pg extension catalog (95749bf)