Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

ClickHouse 11 min read Release hardMaster

What's new in pg_clickhouse v0.10.0: Subqueries, TPC-H Speedups, C Driver, and Aggregates

pg_clickhouse v0.10.0 pushes correlated scalar subqueries, IN and NOT IN down to ClickHouse as remote subqueries and anti/semi-joins, raising full TPC-H pushdown from 12 to 16 of 22 queries. Q17 drops from 32.7 s to 37 ms, beating native PostgreSQL's 2.1 s. A NULL-semantics layer tracks how each expression's result is consumed and injects CASE guards only when operands may be NULL, so ClickHouse's two-valued IN matches PostgreSQL's three-valued logic; transform_null_in is pinned to 0 so a server profile can't break those guards. The release also switches from clickhouse-cpp to the plain-C clickhouse-c driver, which fixes setjmp/longjmp-vs-exception crashes and streams results, and gives each concurrent foreign scan its own connection. Statistical, ordered-set and partitionwise aggregates now push down, and builtin function pushdown is opt-in to preserve Postgres semantics.

Related posts

  • Introducing pg_clickhouse: A Postgres extension for querying ClickHouse

    ClickHouse mediumAdept

    pg_clickhouse v0.1.0 is an Apache 2-licensed PostgreSQL foreign data wrapper, derived from clickhouse_fdw, that runs analytics queries on ClickHouse from Postgres so existing queries can work unmodified by changing search_path. It modernizes the code with PGXS builds, CI across PostgreSQL 13-18 and ClickHouse 22-25, TLS, and Bool/Decimal/JSON types. Its main advance is pushdown: ordered-set aggregates like percentile_cont() are rewritten to ClickHouse quantile() and FILTER clauses become -If combinators. SEMI JOIN pushdown plus planner cost tuning brought 21 of 22 TPC-H queries under 1s, with 12 fully pushed down.

  • pg_clickhouse 0.11.1: Now with pgvector, UPDATE, DELETE pushdown

    ClickHouse mediumAdept

    pg_clickhouse 0.11.1 maps pgvector's vector type to ClickHouse Array(Float32/Float64) columns. It pushes pgvector distance operators down to ClickHouse functions such as L2Distance and cosineDistance, and reports in EXPLAIN whether a ClickHouse vector_similarity HNSW index applies. It also pushes UPDATE and DELETE down as ClickHouse lightweight updates and deletes on MergeTree tables, along with TRUNCATE; lightweight updates need block number/offset settings enabled and suit changes to under about 10% of a table. Other changes include regr_* aggregate pushdown, OrNull aggregates that match Postgres NULL semantics, JSONB subscript pushdown, session timezone alignment, and Decimal(76,38) for unconstrained numeric.

  • Postgres FDW: Pushdown is a negotiation

    ClickHouse hardMaster

    pg_clickhouse, a Postgres foreign data wrapper for ClickHouse, decides clause by clause how much of a query to push down as ClickHouse SQL. One analytical query (join, GROUP BY, FILTER aggregate, percentile, window function, JSON predicate, LIMIT) runs in about 80 ms when fully pushed down, but takes minutes to half an hour when any single clause stays local, because grouped pushdown is all-or-nothing and millions of rows must stream back to Postgres. The post walks through the FDW planner callbacks (GetForeignPaths, GetForeignJoinPaths, GetForeignUpperPaths) and the deparser, then traces shipped steps such as cost-based join pushdown, emitting ALL INNER JOIN to keep Postgres join semantics, and mapping percentile_cont to quantile. It also explains why some translations were refused or revoked when they would have changed results.

  • ClickHouse and PostgreSQL - a Match Made in Data Heaven - part 1

    ClickHouse mediumAdept

    ClickHouse can query PostgreSQL data in place through the postgresql table function and the PostgreSQL table engine. Simple WHERE clauses are pushed down to Postgres, while aggregation, joins, sorting and LIMIT run in ClickHouse. On the 28M-row UK house price dataset, a low-selectivity filter makes Postgres choose a parallel sequential scan over the index, taking about 28s, and querying through ClickHouse gives similar times because Postgres still does the scan. Queries using ClickHouse-specific functions such as toYear are not pushed down and can run much slower. Rewriting joins with conditional aggregates like medianIf, or copying the data into local MergeTree tables, is what delivers the large speedups.

  • What's New in pg_clickhouse v0.3.2: Postgres 19, TLS, Regex, and Memory

    ClickHouse mediumAdept

    pg_clickhouse v0.3.2, the Postgres extension for querying ClickHouse, adds support for PostgreSQL 19 Beta1 and needs no restart or ALTER EXTENSION UPDATE. New CREATE SERVER options cover TLS behavior (`secure` on/off/auto, `min_tls_version`) and native protocol compression. Regex flag pushdown has been corrected, with a mapping table and a warning that Postgres and ClickHouse treat negated character classes differently around newlines. The release also fixes memory ballooning in repeatedly re-scanned parameterized foreign scans and in unbuffered HTTP queries, pushes down capture-free regexp_match(), and fixes empty-array ANY() errors on older ClickHouse.

The quest for software engineering knowledge.

Look:
Layout: