Skip to content

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

ClickHouse 14 min read Deep dive mediumAdept

chDB Durable Layer for agent memory

chDB Durable Layer wraps the embedded chDB (ClickHouse) OLAP engine so a local MergeTree working copy can be published to object storage you own (S3, GCS, Azure) and recovered on another host. Writes stay local until an explicit flush(), checkpoint() folds the statement WAL into a new base snapshot, and a head.json record updated with conditional writes provides a single-writer lease with fencing. It targets agent memory, keeping recall as an in-process query (local was 58x faster than remote in their benchmark) while making state survive ephemeral sandboxes and CI. Recommended practices include append-only versioned memory tables, ZSTD-compressed cold evidence with blobs stored outside the table, flushing at task boundaries, and moving to a server database when multiple writers are needed.

Related posts

  • chDB as the Agent's Local Data Engine

    ClickHouse mediumAdept

    Embedding chDB, the in-process ClickHouse engine, inside an agent keeps hot data local, so tool-call latency is bounded by CPU instead of network round trips, jitter and retries. Agent memory is modeled as an append-only MergeTree table with version and soft-delete columns, which supports semantic recall via cosineDistance, full history and point-in-time queries, plus an optional ReplacingMergeTree materialized view for current state. chDB also acts as a federation hub that joins S3, Postgres, remote ClickHouse and Pandas in one query. The central argument is that over N sequential calls failures compound as (1−p)^N, and each failed call triggers full-context retries and detours, so localizing data cuts token spend as well as latency; the piece closes by pairing chDB with AWS Lambda MicroVMs.

  • No more disks: the architecture behind stateless compute in ClickHouse Cloud

    ClickHouse hardMaster

    ClickHouse Cloud compute nodes are now fully stateless and diskless. The last local dependency, database metadata stored as .sql files, has been removed by a new in-memory Shared database engine backed by a versioned Shared Catalog in Keeper. The architecture got there in stages: SharedMergeTree moved table data to object storage, a distributed cache plus a userspace page cache replaced node-local caching, and the Shared Catalog replaced the Atomic and Replicated database engines. Centralized metadata enables fast bootstrapping without warm-up and DROP operations that don't require every node to be online. It also adds new DDL such as atomic INSERT … SELECT, cross-database RENAME and UNDROP, with selective invalidation of conflicting DDLs instead of a global lock, and extends stateless compute to Iceberg and Delta Lake.

  • Welcome, chDB

    ClickHouse mediumAdept

    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.

  • How does Turso Cloud keep your data durable and safe?

    Turso mediumAdept

    Turso Cloud makes every SQLite database durable on S3 and S3 Express, treating local server disk purely as a cache. Database files are split into 128kB segments grouped into generations, while recent WAL writes are acknowledged only after landing in low-latency S3 Express, with frequent checkpoints (around every 1MB). Segmenting enables lazy fetching, bounded per-tenant local storage and safe replacement of compute nodes. Continuous backups with 90-day point-in-time restore and instant metadata-only branching fall out of the same design.

  • ClickHouse Release 24.10

    ClickHouse mediumAdept

    ClickHouse 24.10 adds a `--copy` mode and an `--implicit-select` calculator mode to clickhouse-local, a CLONE AS clause, real-time query metrics in the client, and a filesystem cache for S3 and Azure files. CLONE AS makes near-instant table copies by hard-linking immutable data parts, so the copy uses no extra storage and the two tables can then diverge independently. The remote file cache keys entries by path plus ETag, caches only the columns a query touches and evicts with LRU. In the example query it cut S3 GetObject calls from 186 to 0 and S3 read time from 16s to 122ms. Refreshable Materialized Views are now production-ready with Replicated database support, and the rewritten MongoDB integration supports all MongoDB data types and pushes down WHERE and ORDER BY.

The quest for software engineering knowledge.

Look:
Layout: