Skip to content

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

ClickHouse 8 min read Case study mediumAdept

Longbridge Technology simplifies their architecture and achieves 10x performance boost with ClickHouse

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. Historical data was migrated via ClickHouse external tables over OSS and Alibaba Cloud DTS, which merged 128 PostgreSQL sub-tables into one table and converted varchar fields to Decimal; Redis was kept for real-time data with ticker-level writes moved to ClickHouse. Reported results include about 5x compression (500GB down to 100GB), 10x faster single-table writes than PostgreSQL, and built-in aggregation and window functions replacing scheduled statistics jobs.

Assumes: columnar databasesPostgreSQL basicstime-series data

Related posts

  • OLTP is expensive, you can ClickHouse it.

    ClickHouse easyNovice

    Data that has stopped changing doesn't need Postgres's ACID machinery, so it can be offloaded to ClickHouse for roughly an order of magnitude better unit economics. Postgres pays for durability, MVCC isolation and synchronous index maintenance on every write: a ~100-byte change touches several 8 KB pages and tens of KB of WAL. It also stores data in uncompressed row pages that thrash the cache once data outgrows RAM. The proposed pattern keeps writes and fresh-row reads in Postgres and replicates settled data to ClickHouse via CDC to serve reads and aggregations, with claimed 10–30× compression and ~100× cheaper aggregations. The cost is slower single-row reads and about a second of eventual consistency. ClickHouse Cloud features (NVMe Postgres, WalShadow CDC, the pg_clickhouse FDW) are pitched as the way to implement it.

  • ClickHouse and PostgreSQL - a Match Made in Data Heaven - part 1

    ClickHouse mediumAdept

    ClickHouse can query PostgreSQL data in place through the postgresql table function and the PostgreSQL table engine. Simple WHERE clauses are pushed down to Postgres, while aggregation, joins, sorting and LIMIT run in ClickHouse. On the 28M-row UK house price dataset, a low-selectivity filter makes Postgres choose a parallel sequential scan over the index, taking about 28s, and querying through ClickHouse gives similar times because Postgres still does the scan. Queries using ClickHouse-specific functions such as toYear are not pushed down and can run much slower. Rewriting joins with conditional aggregates like medianIf, or copying the data into local MergeTree tables, is what delivers the large speedups.

  • ClickHouse and PostgreSQL - a Match Made in Data Heaven - part 2

    ClickHouse mediumAdept

    ClickHouse dictionaries backed by a PostgreSQL source can replace joins against Postgres-resident mapping tables, keeping the data in memory and refreshing it via LIFETIME and an invalidate_query. On the UK house price dataset, a regional price-change query took 48.5s in Postgres, 4.1s in ClickHouse when joining through the PostgreSQL table engine, and 0.44s using dictGet against a complex_key_hashed dictionary. The PostgreSQL table engine also supports "reverse ETL": an INSERT ... SELECT can push aggregated monthly price statistics computed in ClickHouse back into a Postgres summary table for a user-facing application to query.

  • How we migrated Clera’s 500 GB production database to ClickHouse Managed Postgres overnight

    ClickHouse mediumAdept

    Clera moved a 500 GB, 500+ table production Postgres database from the EU to the US overnight onto ClickHouse Managed Postgres, with production traffic still running, using two parallel ClickPipes pipelines. The vendor choice followed a replay of their real workload (hot reads, point lookups, background analytics) on Supabase, Neon, PlanetScale and ClickHouse, plus sysbench TPC-C at 8–128 threads. Local NVMe storage beat network-attached storage, with 16–42% higher TPS than PlanetScale out of the box, and CPU fell from days at 100% to 10–20%. The hard parts were extension portability, restoring triggers, rebuilding indexes, resequencing tables, and doing parity checks before cutover.

  • 92x faster queries: How Open Electricity uses ClickHouse to track Australia’s energy transition in real time

    ClickHouse mediumAdept

    Open Electricity moved the analytical workload behind its public Australian energy API from Postgres/TimescaleDB to ClickHouse, keeping relational data in Postgres. The data is about 1 billion five-minute records, growing by 500k a day. An all-time monthly aggregation dropped from 313 seconds to 3.4 seconds (92x), and to 60 ms with a materialized view, on 4 cores and 4 GB RAM versus Postgres's 16 cores and 32 GB. Lessons from the feature-flagged parallel migration: remember FINAL with ReplacingMergeTree, and encode data completeness into version numbers so partial materialized-view aggregates don't win deduplication. Also standardize on UTC DateTime64 and chunk backfills into 3-day windows of 20k-row batches.

The quest for software engineering knowledge.

Look:
Layout: