Free · WaitlistJoin the waitlist for the free 2-day Vibecoding & AI Agents Intensive (autonomous Hermes + DeepSeek agent · led by Jemal Hamidun, Head of AI at Alpina Digital & MIPT)Join the waitlist →
ReleaseCode / SDK · ActionableHacker News AI→ original

Mason's DuckDB Replica Matched Postgres Answers on 96% of 5,410 Queries

Analytics slow down a production Postgres database, and moving to ClickHouse means rewriting your SQL. Mason is an open-source, read-only replica built on the DuckDB engine that presents itself as Postgres. Across 5,410 slow queries from 159 real databases, it returned the same data as Postgres in 96% of cases (plain DuckDB reached 84.1%). Reports in Metabase or Grafana can be pointed at it with almost no SQL changes.

AI-processed from Hacker News AI; edited by Hamidun News
Mason's DuckDB Replica Matched Postgres Answers on 96% of 5,410 Queries
Source: Hacker News AI. Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceHacker News AI ↗
Editor-in-Chief
Key metric #1CedarDB matched Postgres on 88.1% of queries but gave wrong results on 3.9%
Key metric #2pg_clickhouse refused to run 39.9% of queries because of syntax differences
Key metric #3On the remaining 4%, Mason returns an error with a hint on how to rewrite the SQL

A familiar picture: a product database runs on Postgres, then analysts arrive with dashboards and one-off reports, and heavy queries start choking the main workload. The classic fix is to move analytics into a separate columnar database, but then you have to rewrite your SQL for a new dialect. The Mason team posted their answer on Hacker News (81 points): an open-source, read-only Postgres replica that runs queries on the DuckDB columnar engine but looks like ordinary Postgres from the outside. The test was simple. The authors took 5,410 queries that ran slowly on Postgres and checked whether Mason would return exactly the same data as Postgres itself. It did, in 96% of cases.

Why not ClickHouse, and what else was ruled out

The authors started with the obvious option: connect ClickHouse to client Postgres databases and run analytics there. Two problems surfaced quickly. First, for ClickHouse to be fast, you need to know in advance which queries will arrive and tune the engine for them. Second, its SQL differs noticeably from Postgres SQL. For one-off queries whose shape you cannot predict, that approach did not work. The team stresses that they like ClickHouse: it is "insanely fast" when the queries are known in advance.

Next, several options were dropped based on documentation alone, without testing:

  • pg_mooncake: in the authors' impression, the project stalled after Databricks acquired it;
  • pg_duckdb: it delivers either fast queries or fresh data, but they needed both;
  • Materialize, RisingWave and Readyset: like ClickHouse, they require knowing query shapes in advance;
  • Firebolt: its license prevents offering it to clients;
  • Redshift, AlloyDB and similar: tied to a cloud provider.

Three candidates made the shortlist: pg_clickhouse (a Postgres extension that parses SQL and hands the work to ClickHouse), CedarDB (a closed-source analytical database compatible with Postgres), and DuckDB (an embeddable open-source columnar engine with a dialect similar to Postgres).

How they tested and what they found

The test used real material. The team took 5,410 hand-written queries that ran slowly on Postgres, drawn from 159 real databases. They generated data from each database's schema and spun up 159 local copies. Every query was run on Postgres and on the three candidates, and the results were compared. "Matched" means the answer was exactly equal to Postgres's answer. "Refused" means the tool returned an error, most often about unrecognized syntax. "Wrong" means the query ran but the result differs from Postgres. The authors treated Postgres as the reference, although they acknowledge that Postgres can sometimes be the one that is wrong.

Results:

  • pg_clickhouse: matched 59.4%, refused 39.9%, wrong 0.8%;
  • CedarDB: matched 88.1%, refused 8%, wrong 3.9%;
  • DuckDB: matched 84.1%, refused 14.3%, wrong 1.6%.

They chose DuckDB. CedarDB's code is closed, while DuckDB's open license lets the team fix the "long tail" of incompatibilities themselves. That is how Mason came about. It now matches Postgres on 96% of the same 5,410 queries and on hundreds added on top. It has also been checked with Metabase, Grafana, Superset, DBeaver and Trevor.io. On the remaining 4%, Mason returns a clear error with a hint on how to rewrite the SQL.

What this means in practice

For teams whose analytics are bottlenecked on Postgres, the idea is pragmatic: don't change dialects or learn a new engine, just put a replica alongside that computes the same queries faster. This is especially useful when reports are written by people rather than fixed services.

There are caveats. The test used synthetic data generated from schemas, so the post does not show speed at production volumes. There are no concrete speedup figures either; the authors only write "very fast." Compatibility was measured on the team's own query set, so your results may differ. The project is new, and 4% of queries will still need manual rewriting.

The method itself is worth adopting: before choosing an analytics engine, run your accumulated slow queries through it and measure three shares: matched, refused, and wrong. The share of silent discrepancies, rather than speed, often decides whether a tool can be trusted with reports.

Story

Key Questions Answered

Why not ClickHouse, and what else was ruled out?

The authors started with the obvious option: connect ClickHouse to client Postgres databases and run analytics there. Two problems surfaced quickly. First, for ClickHouse to be fast, you need to know in advance which queries will arrive and tune the engine for them. Second, its SQL differs noticeably from Postgres SQL. For one-off queries whose shape you cannot predict, that approach did not work. The team stresses that they like ClickHouse: it is "insanely fast" when the queries are known in advance.

How they tested and what they found?

The test used real material. The team took 5,410 hand-written queries that ran slowly on Postgres, drawn from 159 real databases. They generated data from each database's schema and spun up 159 local copies. Every query was run on Postgres and on the three candidates, and the results were compared. "Matched" means the answer was exactly equal to Postgres's answer. "Refused" means the tool returned an error, most often about unrecognized syntax. "Wrong" means the query ran but the result differs from Postgres.

What this means in practice?

For teams whose analytics are bottlenecked on Postgres, the idea is pragmatic: don't change dialects or learn a new engine, just put a replica alongside that computes the same queries faster. This is especially useful when reports are written by people rather than fixed services. There are caveats. The test used synthetic data generated from schemas, so the post does not show speed at production volumes.

ZK
Zhemal Khamidun — CPO at Alpina Digital, product manager of AlpinaGPT. Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Unified AI Workspace · Nomad

Test Frontier LLMs & Autonomous Agents in One Workspace

Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.

Try Nomad AI →Launch Nomad Agent
What do you think?
Loading comments…