Introducing Postgres Query Insights in ClickHouse Cloud
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.
Related posts
- pg_stat_ch: a PostgreSQL extension that exports every metric to ClickHouse
ClickHouse hardMaster
pg_stat_ch is an open-source (Apache 2.0) PostgreSQL 16–18 extension that captures every statement execution, including failed queries and DDL, as a fixed-size ~4.6KB event with 45 fields and streams it to ClickHouse for APM-style analysis. On the hot path each backend memcpys the event into a cache-line-padded shared-memory ring buffer. A background worker flushes batches once a second over ClickHouse's native protocol with LZ4 compression, and materialized views handle all aggregation on the ClickHouse side. Key design choices are fixed-size events for predictable memory (query text is truncated at 2KB), dropping events instead of applying back-pressure, and a try-lock path with per-backend batching that cuts lock acquisitions about 5x. On pgbench TPC-B with 32 clients, extension code costs about 2% CPU but throughput drops about 11% because of contention on the enqueue lock.
- London Meetup Report: Scaling Analytics with PostHog and Introducing HouseWatch
ClickHouse mediumAdept
PostHog scaled its product analytics platform by moving from Postgres to ClickHouse, with an events table holding roughly 62 TB uncompressed for a single column. Two optimizations drove most of the gains: materializing frequently queried JSON properties into columns, and a person overrides table that records merged user IDs with versions, is joined at query time, and is periodically rolled back into the events. Together these cut Y Combinator's average query time from 18s to 1s and P95 from 60s to 4s, and a user-facing sampling control lets users trade accuracy for speed. PostHog also introduced HouseWatch, an open-source React app deployed via Docker for monitoring long-running ClickHouse queries, analyzing table and column disk usage, killing queries, and managing migrations.
- Postgres at Open House NYC
ClickHouse easyNovice
ClickHouse used its Open House NYC keynote to launch WalShadow, an open-source engine that replicates Postgres into ClickHouse from the physical WAL instead of logical replication. It decodes WAL outside the source and uses a schema-only shadow Postgres to track DDL, effectively making ClickHouse an analytical physical standby. On 8-vCPU instances it showed about 200 ms commit-to-visible latency and 300K rows/s, versus about 10 s and 120K rows/s for PeerDB. The keynote also opened a Google Cloud private preview of ClickHouse Managed Postgres and released a chdb Postgres extension that extends COPY to import from S3, GCS and Azure and outperformed DuckDB-based extensions on the NYC Taxi import benchmark.
- LangChain - Why we Choose ClickHouse to Power LangSmith
ClickHouse mediumAdept
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.
- “Just OLAP it”: How Ramp rebuilt its analytics platform on ClickHouse Cloud
ClickHouse mediumAdept
Ramp moved customer-facing spend analytics off its Postgres monolith after enterprise customers' reports on a single card-transactions table began taking 40+ seconds, and now serves them in milliseconds from ClickHouse Cloud. The pipeline streams Postgres CDC via Debezium into per-table Kafka topics. Stateless Python enrichers denormalize the records, and a connector loads them into ReplacingMergeTree tables, with recurring OPTIMIZE and FINAL queries handling deduplication. A local benchmark of 60M transactions partitioned by business ID ran 16,000 randomized queries in 12 seconds, and a four-engineer pod shipped to production in about two months. The platform now backs in-app Reporting and Budgets, and Ramp plans to add enriched tables for every core data type.