Documentation Index
Fetch the complete documentation index at: https://private-7c7dfe99-page-updates.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
pg_clickhouse
Introduction
pg_clickhouse, an open-source PostgreSQL extension, runs analytics queries on ClickHouse right from PostgreSQL without rewriting any SQL. It supports PostgreSQL 13 and later and ClickHouse v23 and later. Once ClickPipes starts syncing data ClickHouse, use pg_clickhouse to quickly and easily import foreign tables into a PostgreSQL schema. Then run your existing PostgreSQL queries to against those tables, preserving your existing code base while pushing execution down to ClickHouse.Getting Started
The simplest way to try pg_clickhouse is the Docker image, which contains the standard PostgreSQL Docker image with the pg_clickhouse extension:Test Case: TPC-H
This table compares TPC-H query performance between regular PostgreSQL tables and pg_clickhouse connected to ClickHouse, both loaded at scaling factor 1; ✔︎ indicates full pushdown, while a dash indicates a query cancellation after 1m. All tests run on a MacBook Pro M4 Max with 36 GB of memory.| Query | PostgreSQL | pg_clickhouse | Pushdown |
|---|---|---|---|
| [Query 1] | 4693 ms | 268 ms | ✔︎ |
| [Query 2] | 458 ms | 3446 ms | |
| [Query 3] | 742 ms | 111 ms | ✔︎ |
| [Query 4] | 270 ms | 130 ms | ✔︎ |
| [Query 5] | 337 ms | 1460 ms | ✔︎ |
| [Query 6] | 764 ms | 53 ms | ✔︎ |
| [Query 7] | 619 ms | 96 ms | ✔︎ |
| [Query 8] | 342 ms | 156 ms | ✔︎ |
| [Query 9] | 3094 ms | 298 ms | ✔︎ |
| [Query 10] | 581 ms | 197 ms | ✔︎ |
| [Query 11] | 212 ms | 24 ms | |
| [Query 12] | 1116 ms | 84 ms | ✔︎ |
| [Query 13] | 958 ms | 1368 ms | |
| [Query 14] | 181 ms | 73 ms | ✔︎ |
| [Query 15] | 1118 ms | 557 ms | |
| [Query 16] | 497 ms | 1714 ms | |
| [Query 17] | 1846 ms | 32709 ms | |
| [Query 18] | 5823 ms | 10649 ms | |
| [Query 19] | 53 ms | 206 ms | ✔︎ |
| [Query 20] | 421 ms | - | |
| [Query 21] | 1349 ms | 4434 ms | |
| [Query 22] | 258 ms | 1415 ms |
Compile From Source
General Unix
The PostgreSQL and curl development packages includepg_config and
curl-config in the path, so you should be able to just run make (or
gmake), then make install, then in your database
CREATE EXTENSION pg_clickhouse.
Debian / Ubuntu / APT
See PostgreSQL Apt for details on pulling from the PostgreSQL Apt repository.RedHat / CentOS / Yum
Install From PGXN
With the above dependencies satisfied use the PGXN client (available as Homebrew, Apt and Yum packages namedpgxnclient) to download, compile,
and install pg_clickhouse:
Compile and Install
To build and install the ClickHouse library andpg_clickhouse, run:
pg_config:
curl-config isn’t in the path on you host, you can specify the path
explicitly:
gmake:
pg_config installed and in your path. If you used a
package management system such as RPM to install PostgreSQL, be sure that the
-devel package is also installed. If necessary tell the build process where
to find it:
prefix argument to install (but no other make targets):
postgresql.conf
parameters:
Testing
To run the test suite, once the extension has been installed, runLoading
Oncepg_clickhouse is installed, you can add it to a database by connecting
as a super user and running:
pg_clickhouse and all of its supporting objects into
a specific schema, use the SCHEMA clause to specify the schema, like so:
Dependencies
Thepg_clickhouse extension requires PostgreSQL 13 or higher, libcurl,
libuuid. Building the extension requires a C and C++ compiler, libSSL, GNU
make, and CMake.
Road Map
Our top focus is finishing pushdown coverage for analytic workloads before adding DML features. Our road map:- Get the remaining 10 un-pushed-down TPC-H queries optimally planned
- Test and fix pushdown for the ClickBench queries
- Support transparent pushdown of all PostgreSQL aggregate functions
- Support transparent pushdown of all PostgreSQL functions
- Allow server-level and session-level ClickHouse settings via CREATE SERVER and GUCs
- Support all ClickHouse data types
- Support lightweight DELETEs and UPDATEs
- Support batch insertion via COPY
- Add a function to execute an arbitrary ClickHouse query and return its results as a tables
- Add support for pushdown of UNION queries when they all query the remote database
Authors
Copyright
- Copyright (c) 2025-2026, ClickHouse
- Portions Copyright (c) 2023-2025, Ildus Kurbangaliev
- Portions Copyright (c) 2019-2023, Adjust GmbH
- Portions Copyright (c) 2012-2019, PostgreSQL Global Development Group