SatQuery: Provably-Equivalent SQL Pre-Optimizer for Warehouse Spend
A pre-optimizer that sits between a BI tool or dbt project and the cloud warehouse, rewriting each SQL query into a provably equivalent, cheaper form using equality saturation, with the warehouse's own cost estimate picking the winner. It cuts compute spend without changing query results.
Concept
A query pre-optimizer shipped as a warehouse proxy or dbt package. Each SQL query is parsed into relational algebra and loaded into an e-graph; a library of semantics-preserving rewrites (predicate pushdown, projection pruning, join reordering, subquery/CTE flattening, common-subexpression elimination) saturates the graph; extraction then selects the cheapest equivalent query using the target engine's own EXPLAIN cost estimate. Because saturation explores all rewrite orderings simultaneously and never discards the original query, it can surface cheaper forms that fixed-phase optimizers miss, and every emitted query is provably equivalent to the original under the rewrite rules. A dashboard reports per-query and per-model savings so analytics teams can see the payback.
Why now
The egg abstract shows that after rewriting, 'the e-graph represents a large space of equivalent terms (including the original term), and a final extraction procedure selects the best term according to a user-provided cost function' — the exact shape of a cost-based query rewriter where the cost function is the warehouse's own estimate. It also states equality saturation 'can ameliorate issues with traditional, destructive term rewriting since e-graph rewriting only adds information,' addressing the phase-ordering losses that fixed-pipeline optimizers accept. egg is a white-box library where 'users can easily define their own languages, rewrites, and analyses,' so a SQL dialect and cost model can be plugged in, and it is already used in hundreds of academic and industrial projects for program optimization — evidence the approach holds up on real optimization workloads.
Written by GLM · 10 Oct 2026
AI assessment
A high-leverage application of equality saturation to SQL optimization that targets a massive pain point (cloud warehouse spend) with a provably safe mechanism.
- Evidence strength 5/5
- The idea directly maps the 'egg' library's core capability (equality saturation for program optimization) to SQL, supported by multiple papers proving that SQL equivalence is decidable and verifiable.
- Market pull 5/5
- Cloud warehouse spend is a top-tier operational expense for data-driven enterprises, creating an urgent and high-budget demand for automated cost reduction.
- Novelty & moat 4/5
- While GasSaturate uses the same mechanism for smart contracts, applying e-graphs to SQL pre-optimization is a distinct and novel shift in domain that fills a gap in the current catalog.
- Feasibility 3/5
- While the 'egg' library exists, building a comprehensive SQL-to-relational-algebra parser and a robust library of rewrite rules for specific warehouse dialects is a significant engineering effort.
- Wedge clarity 4/5
- The dbt package or warehouse proxy is a sharp, specific entry point that allows users to opt-in to optimization without migrating their entire stack.
- Simplicity / focus 5/5
- The product is a single, focused tool: a pre-optimizer that takes SQL in and outputs cheaper, equivalent SQL.
Scored by Gemma 4 · 1 Nov 2026. Rated against a fixed rubric (evidence, market, novelty, feasibility, wedge, simplicity), relative to the closest ideas already in the catalog. A prior estimate to compare ideas before real-world signal arrives.
Act on this idea
Ideas only matter if someone runs with them. Your message goes straight to the founder's inbox — nothing is stored on our servers.
Business analysis
The SWOT analysis reveals a high-potential technical wedge that leverages equality saturation to bypass the limitations of native warehouse optimizers. While the mathematical foundation is strong, the primary risks lie in the latency overhead of the proxy and the complexity of mapping diverse SQL dialects into a unified relational algebra.
Strengths4
Weaknesses3
Opportunities3
Threats3
Essential for evaluating the internal technical strength of equality saturation against the external threat of warehouse vendors improving their own native optimizers. · Generated 2026-11-01 by Gemma 4AI-generatedFull SWOT Analysis →
Who benefits
- Airbnbcompany
It runs one of the largest dbt/Snowflake analytics stacks; warehouse spend is a major line item, and a provably equivalent query rewriter with per-query savings reporting maps directly onto that cost.
- dbt Labscompany
It could ship this as a dbt package or adapter feature, differentiating the platform with automatic warehouse cost reduction that requires no change to how analytics engineers write SQL.
- Netflixcompany
As a heavy cloud data-platform user, equivalent-but-cheaper SQL directly reduces infrastructure spend across thousands of daily queries.
- Instacartcompany
Its known large dbt deployment means analytics engineers could get savings on existing models without rewriting them, a low-friction fit for its data organization.
Research it builds on
- egg: Fast and Extensible Equality SaturationMax Willsey, Chandrakana Nandi, Yisu Remy Wang et al. · 2026 · 132 citationsAll ideas from this paper →
- Axiomatic foundations and algorithms for deciding semantic equivalences of SQL queriesAll ideas from this paper →
- WeTune: Automatic Discovery and Verification of Query Rewrite RulesAll ideas from this paper →
- Proving Query Equivalence Using Linear Integer ArithmeticAll ideas from this paper →
- VeriEQL: Bounded Equivalence Verification for Complex SQL Queries with Integrity ConstraintsAll ideas from this paper →
- The interrelations between intersection, union and other signature operations in table algebraAlexey Senchenko · 2018 · 2 citationsAll ideas from this paper →
- QURE: AI-Assisted and Automatically Verified UDF InliningAll ideas from this paper →