---
title: "The Journey to Zero-Copy: How chDB Became the Fastest SQL Engine on Pandas DataFrame"
description: "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."
url: "https://swe.quest/articles/the-journey-to-zero-copy-how-chdb-became-the-fastest-sql-engine-on-pandas-b4ab858523515f13"
canonical: "https://clickhouse.com/blog/chdb-journey-to-zero-copy"
source: "ClickHouse"
published: "2026-01-09"
difficulty: "medium"
kind: "Case study"
reading_minutes: 8
tags: ["python","performance","analytics","query-engines"]
---

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

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2026-01-09, 8 min read, Case study. Original: [https://clickhouse.com/blog/chdb-journey-to-zero-copy](https://clickhouse.com/blog/chdb-journey-to-zero-copy)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Python](https://swe.quest/tags/python.md) (Languages)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Query engines](https://swe.quest/tags/query-engines.md) (Data & databases)

## Prerequisites

- Pandas DataFrames
- Python GIL ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- columnar OLAP engines ([easy posts on Analytics & OLAP](https://swe.quest/tags/analytics.md?difficulty=easy))

## Keywords

chDB, ClickHouse, Pandas, NumPy, DuckDB, ClickBench, CPython

## Related posts

- [How we made querying Pandas DataFrames with chDB 87x faster](https://swe.quest/articles/how-we-made-querying-pandas-dataframes-with-chdb-87x-faster-1ee5b7d8017e769d.md): ClickHouse · 2024-08-29 · Medium · 8 min read · Python, Performance engineering, Query engines, Analytics & OLAP, C & C++
  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.
- [Announcing chDB 4: write Pandas, run ClickHouse, now on Hex](https://swe.quest/articles/announcing-chdb-4-write-pandas-run-clickhouse-now-on-hex-3e3042b3b93d1f1e.md): ClickHouse · 2026-03-11 · Medium · 11 min read · Analytics & OLAP, Query engines, Python, Performance engineering
  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.
- [Welcome, chDB](https://swe.quest/articles/welcome-chdb-80fea87c647d8ab8.md): ClickHouse · 2023-08-31 · Medium · 7 min read · Analytics & OLAP, Python, Databases, Open source
  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.
- [Querying Pandas DataFrames with ClickHouse](https://swe.quest/articles/querying-pandas-dataframes-with-clickhouse-f6443dd364e0e7c9.md): ClickHouse · 2023-11-15 · Medium · 4 min read · Python, Analytics & OLAP, SQL
  chDB, an embedded Python library built on the ClickHouse engine, can run SQL directly against Pandas DataFrames through the chdb.dataframe module.
- [chDB - A Rocket Engine on a Bicycle](https://swe.quest/articles/chdb-a-rocket-engine-on-a-bicycle-951148e84c12126b.md): ClickHouse · 2023-09-29 · Hard · 9 min read · Analytics & OLAP, Memory management, C & C++, Python, Performance engineering
  chDB embeds the ClickHouse engine as an in-process Python module instead of shelling out to the 500MB clickhouse-local binary, using WriteBufferFromVector, Python memoryview and Pybind11 for zero-copy result retrieval.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
