Skip to content

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

ClickHouse 7 min read Announcement mediumAdept

Welcome, chDB

chDB is a community-built embedded SQL OLAP engine that packages ClickHouse as an in-process Python module, similar in spirit to DuckDB, for local analytics, ETL and exploration without running a server. Instead of shelling out to clickhouse-local via pipes, which adds 10–50 ms of process startup per query and copies results, chDB hooks into ClickHouse's read/write buffers and exchanges data through MemoryView. Examples show querying Parquet and gzipped CSV on S3 with schema inference, returning results as CSV, Pandas DataFrames or Arrow tables, and running SQL directly over DataFrames. Bindings for Rust, Node.js and Go, persistent sessions backed by MergeTree, UDFs and ARM64 support are in progress or recently added.

Related posts

  • How we made querying Pandas DataFrames with chDB 87x faster

    ClickHouse mediumAdept

    chDB, the in-process embedded ClickHouse, sped up SQL queries over Pandas DataFrames 87x by replacing its original Parquet serialize/deserialize round-trip through file descriptors with a native Python table engine that reads Python objects directly. The new engine is built from a TableFunctionPython, StoragePython and PythonSource that feed ClickHouse's concurrent pipeline. To keep multi-threaded execution from serializing on the GIL and to avoid reference-counting pitfalls, the team concentrated CPython API calls before the pipeline runs, batched copies with SIMD memcpy, and reimplemented Python str encoding conversion in C++. Together these changes cut ClickBench Q23 from over 30s to 0.56s and put chDB ahead of DuckDB in the SQL-on-DataFrame benchmark. chDB v2.0.2 also adds chdb.PyReader for user-defined Python table functions, demonstrated by querying the Google Calendar API with SQL.

  • Announcing chDB 4: write Pandas, run ClickHouse, now on Hex

    ClickHouse mediumAdept

    chDB 4 adds DataStore, a Pandas-compatible API that records operations lazily as a chain of LazyOps, then compiles them into ClickHouse SQL with filter pushdown, column pruning and limit propagation, executing in-process on the ClickHouse engine. A query planner splits pipelines into segments when an operation has no ClickHouse equivalent, handing data to Pandas and back via memoryview and the Python() table function with near-zero-copy exchange for fixed-width columns. Pandas segments act as optimization barriers, so Pandas-only operations are best placed late in the pipeline. Row-ID tracking preserves source ordering, with an optional performance mode that skips it. Automatic caching serves notebook workflows, and NaN/NULL, string sort order and integer overflow semantics are documented differences from Pandas. It ships pre-installed in Hex notebooks.

  • Introducing chdb Postgres extension: High-performance imports from cloud storage

    ClickHouse mediumAdept

    chdb is a new Postgres extension that uses the in-process ClickHouse engine chDB to import and export data in dozens of formats (CSV, JSON, Parquet, Avro, Arrow, ORC, Protobuf and more) from S3, GCS, Azure, HDFS, HTTP and local files, via a chdb_query() function and a chdb_hook module that extends COPY and CREATE TABLE. Importing a 1M-row NYC Taxi dataset from S3, pg_duckdb and pg_lake took 2-3x longer than chdb, and only aws_s3, which supports far fewer formats, came close. Rather than linking chDB into the backend or running a persistent service, chdb starts a helper process on demand and streams ClickHouse Native-format results over file descriptors, then exits, so the Postgres server pays no lasting memory cost and is isolated from out-of-memory failures. Type mapping goes through pg-clickhouse-c, with a structure option to override mappings such as Postgres JSON to ClickHouse JSON.

  • Querying Pandas DataFrames with ClickHouse

    ClickHouse mediumAdept

    chDB, an embedded Python library built on the ClickHouse engine, can run SQL directly against Pandas DataFrames through the chdb.dataframe module. DataFrames are passed as named parameters and referenced in SQL as __name__. The walkthrough uses Kaggle Canadian house-price data to show aggregation with GROUP BY ALL, joining two DataFrames, re-querying the resulting chDB Table via __table__, and converting results back with to_pandas(). It needs pandas and pyarrow installed, and string columns come back as bytes, so filters must compare against values like b"Ontario".

  • The Journey to Zero-Copy: How chDB Became the Fastest SQL Engine on Pandas DataFrame

    ClickHouse mediumAdept

    chDB, ClickHouse embedded as a Python library, removed the four serialization steps that made every v1 query take over 100ms by reading Pandas DataFrames in place. That change alone made v2 87x faster than v1. The engineering work included automatic variable discovery via Python(df), batching CPython calls before parallel execution to avoid GIL contention, and reimplementing Python string-to-UTF-8 encoding in C++, which cut one ClickBench query from 8.6s to 0.56s. v4.0 adds zero-copy output by mapping ClickHouse columns directly to NumPy dtypes. In the post's own benchmarks, exporting 1M rows to a DataFrame took about 24% less time than DuckDB, and chDB beat Pandas at most operations on 1M and 10M rows.

The quest for software engineering knowledge.

Look:
Layout: