Skip to content

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

ClickHouse 9 min read Case study mediumAdept

LangChain - Why we Choose ClickHouse to Power LangSmith

LangSmith, LangChain's LLM observability and evaluation platform, began fully on Postgres but outgrew it as users logged most of their production traces: ingestion lagged, precomputed materializations were rigid and costly, and lock contention grew. LangChain added ClickHouse rather than Druid or Pinot because it accepts plain INSERTs without Kafka-based ingestion services and runs locally, self-managed and in the cloud. Lessons include designing sorting keys carefully, using ReplacingMergeTree for updates, and leaning on EXPLAIN because the query planner is less forgiving than Postgres. For trace-ID lookups outside the sorting key, materialized views act as an inverted index that maps trace and run IDs to the main table's sorting-key values, avoiding full scans more simply than bloom-filter skip indices.

Assumes: OLAP databasesClickHouse sorting keysmaterialized views

Related posts

  • How Langfuse is scaling LLM observability for the agentic era with ClickHouse Cloud

    ClickHouse mediumAdept

    Langfuse moved its LLM tracing data from a single-node Postgres instance to ClickHouse after ingestion growth caused timeouts, high IOPS costs and slow SDK ingestion. The new pipeline routes SDK and OTel events through Redis queues and S3 to async workers, with ClickHouse as the analytical engine, and query latency fell from minutes to near real-time. Lessons from running it at scale include passing primary keys such as timestamps through frontend state, testing alternative data models against production data, and using compute-compute separation to protect UI queries from ingestion spikes. Because mutable span updates with ReplacingMergeTree and heavy trace/span joins became costly, Langfuse is moving to a wide, immutable events table that cut memory use about 3x and made queries up to 20x faster, with legacy data backfilled in the background.

  • How Respan is scaling LLM observability with ClickHouse Cloud

    ClickHouse mediumAdept

    Respan, an AI gateway with built-in LLM observability processing about 50 million events per day, moved ingestion and analytics from Postgres to ClickHouse Cloud after per-request transactional inserts began contending at 50-100 writes per second. The ClickHouse design keeps rows small by storing typed metric columns and truncating prompt and output text. Incremental materialized views cascade minute-level rollups into hourly rollups per dimension, while refreshable materialized views update user-metadata joins every 10 minutes. Trace spans arrive asynchronously and are linked to parents at query time, and argMax-style aggregates replace the expensive FINAL modifier so trace analytics stay memory-efficient at billions of rows.

  • Introducing Postgres Query Insights in ClickHouse Cloud

    ClickHouse mediumAdept

    Postgres Query Insights, now in preview for ClickHouse Cloud Managed Postgres, ranks every normalized query pattern by impact and aggregates per-execution counters (CPU, cache vs disk reads, temp spills, unlaunched parallel workers, WAL) to explain why a pattern is slow. A worked example traces a p99 regression to a sort spilling to disk, confirmed with EXPLAIN (ANALYZE, BUFFERS) and fixed with an index or work_mem tuning. Telemetry comes from pg_stat_ch, an Apache 2.0 extension that normalizes literals at parse-analyze time so values and PII never leave the database. It enqueues raw per-statement events via a non-blocking try-lock on a shared-memory ring buffer at about 3% overhead, dropping events under pressure rather than back-pressuring Postgres.

  • How we used ClickHouse to store OpenTelemetry Traces and up our Observability Game

    ClickHouse mediumAdept

    Resmo stores over 300 million unsampled OpenTelemetry spans per day in a self-hosted ClickHouse node, after dropping S3/Parquet/Athena because of its 2-3 second query startup and delayed data. A single c7g.xlarge with 400 GB EBS holds more than 4 billion spans at about 92% compression (275 GiB vs 3.4 TiB). LowCardinality materialized columns for tenant and user IDs speed up common queries, and joins to Aurora Postgres add account names. The post shares SQL for latency percentiles, SpanAttributes key analysis, spans-per-trace histograms and exception-message search with hasToken.

  • Lago - Using ClickHouse to Scale an Events Engine

    ClickHouse mediumAdept

    Lago, an open-source usage-based billing platform ingesting millions of events per minute, moved its streamed billable events from Postgres to ClickHouse Cloud and kept Postgres for all other transactional data. The ClickHouse side is small: a Kafka-engine queue table, a materialized view that maps event metadata from JSON into a string array, and a MergeTree raw_events table keyed on organization, subscription, code and timestamp. Aggregation queries got 18x to 137x faster; for example, a weighted sum dropped from 6.6s to 48ms. The post also covers OLTP vs OLAP tradeoffs, columnar storage, insert-time materialized views and vectorized execution.

The quest for software engineering knowledge.

Look:
Layout: