# QueryBrew lets PostgreSQL and ClickHouse borrow Umbra's query optimizer

Original title: QueryBrew: System-Agnostic SQL-to-SQL Query Optimization \[pdf\]

> Hacker News story 49666155 · language: en · submitted 2026-09-11
> Web version: https://zeli.app/story/49666155
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 31 · by [matt_d](<https://news.ycombinator.com/user?id=matt_d>) · 💬 10
[original](<https://www.vldb.org/pvldb/vol19/p4494-schmidt.pdf>) · [HN discussion](<https://news.ycombinator.com/item?id=49666155>)

## Summary

QueryBrew is a system-agnostic optimization service that rewrites SQL into SQL: it feeds a query to the state-of-the-art Umbra optimizer, then distills the resulting plan back into operator-oriented SQL using one CTE per operator. Any target database — PostgreSQL, DuckDB, ClickHouse, or SQL Server — can inherit general unnesting, simplification, and adaptive join ordering without modification. On correlated and many-join queries, runtimes improve by more than an order of magnitude; ClickHouse even returned a wrong result on the original query but the correct one after optimization.

## Key quote

> To our surprise, ClickHouse (version 25.11) returns the wrong result for the original query; however, running the optimized version produces the correct result.

## HN discussion (10 comments)

### [schultzer](<https://news.ycombinator.com/item?id=49667071>)

> It’s not clear from the paper or their website how it works, the paper seams to talk about an optimizer where the websites states its AI maybe this is just slop. Hard to determine when skimming it, although seams like a neat idea if it’s a proper engine and not just AI that anyone could copy and paste into a chat with the statistics.

### [remywang](<https://news.ycombinator.com/item?id=49667240>)

> Very practical approach to “query optimizer as a service”, but I find it cursed that we have decided SQL is the IR for databases

---

## Cite

- Page: https://zeli.app/story/49666155
- Date: 2026-09-11
- Source: vldb.org (https://www.vldb.org/pvldb/vol19/p4494-schmidt.pdf)
- Hacker News: https://news.ycombinator.com/item?id=49666155

## Other languages

- zh: https://zeli.app/zh/story/49666155 · markdown: https://zeli.app/zh/story/49666155.md
- ja: https://zeli.app/ja/story/49666155 · markdown: https://zeli.app/ja/story/49666155.md
- ko: https://zeli.app/ko/story/49666155 · markdown: https://zeli.app/ko/story/49666155.md
- de: https://zeli.app/de/story/49666155 · markdown: https://zeli.app/de/story/49666155.md
- es: https://zeli.app/es/story/49666155 · markdown: https://zeli.app/es/story/49666155.md
- ru: https://zeli.app/ru/story/49666155 · markdown: https://zeli.app/ru/story/49666155.md
