---
title: "How we made querying Pandas DataFrames with chDB 87x faster"
description: "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."
url: "https://swe.quest/articles/how-we-made-querying-pandas-dataframes-with-chdb-87x-faster-1ee5b7d8017e769d"
canonical: "https://clickhouse.com/blog/chdb-pandas-dataframes-87x-faster"
source: "ClickHouse"
published: "2024-08-29"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 8
tags: ["python","performance","query-engines","analytics","c-cpp"]
---

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

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2024-08-29, 8 min read, Deep dive. Original: [https://clickhouse.com/blog/chdb-pandas-dataframes-87x-faster](https://clickhouse.com/blog/chdb-pandas-dataframes-87x-faster)

## Summary

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.

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)
- [Query engines](https://swe.quest/tags/query-engines.md) (Data & databases)
- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [C & C++](https://swe.quest/tags/c-cpp.md) (Languages)

## Prerequisites

- Python GIL ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- Pandas DataFrames
- CPython C API basics
- columnar query engines ([easy posts on Query engines](https://swe.quest/tags/query-engines.md?difficulty=easy))

## Keywords

chDB, ClickHouse, Pandas, CPython, DuckDB, ClickBench, PyArrow, GIL

## Related posts

- [The Journey to Zero-Copy: How chDB Became the Fastest SQL Engine on Pandas DataFrame](https://swe.quest/articles/the-journey-to-zero-copy-how-chdb-became-the-fastest-sql-engine-on-pandas-b4ab858523515f13.md): ClickHouse · 2026-01-09 · Medium · 8 min read · Python, Performance engineering, Analytics & OLAP, Query engines
  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.
- [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.
- [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.
- [Longbridge Technology simplifies their architecture and achieves 10x performance boost with ClickHouse](https://swe.quest/articles/longbridge-technology-simplifies-their-architecture-and-achieves-10x-e3a982c02b6e4b33.md): ClickHouse · 2025-03-17 · Medium · 8 min read · Analytics & OLAP, Databases, PostgreSQL, Payments & fintech
  Longbridge, a Singapore online brokerage, replaced a fragmented market-data stack of PostgreSQL (historical), Redis (real-time) and DynamoDB (high-write) with ClickHouse after evaluating it against TimescaleDB and TDengine for write throughput, Decimal support, time functions and aggregations.

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)
