QueryBrew lets PostgreSQL and ClickHouse borrow Umbra's query optimizer

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

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.

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

More from this day

2026-09-11