QED: A Powerful Query Equivalence Decider for SQL
Shuxian Wang, Sicheng Pan, Alvin Cheung
Abstract
Checking query equivalence is of great significance in database systems. Prior work in automated query equivalence checking sets the first steps in formally modeling and reasoning about query optimization rules, but only supports a limited number of query features. In this paper, we present Qed, a new framework for query equivalence checking based on bag semantics. Qed uses a new formalism called Q-expressions that models queries using different normal forms for efficient equivalence checking, and models features such as integrity constraints and NULLs in a principled way unlike prior work. Our formalism also allows us to define a new query fragment that encompasses many real-world queries with a complete equivalence checking algorithm, assuming a complete first-order theory solver. Empirically, Qed can verify 299 out of 444 query pairs extracted from the Calcite framework and 979 out of 1287 query pairs extracted from CockroachDB, which is more than 2× the number of cases proven by prior state-of-the-art solver.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
7 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- ParSEval: Plan-aware Test Database Generation for SQL Equivalence Evaluation cites SPES: A Symbolic Approach to Proving Query Equivalence Under Bag Semantics
- Proving Cypher Query Equivalence cites SPES: A Symbolic Approach to Proving Query Equivalence Under Bag Semantics
- SpotIt: Evaluating Text-to-SQL Evaluation with Formal Verification cites SPES: A Symbolic Approach to Proving Query Equivalence Under Bag Semantics
- Optimal Predicate Pushdown Synthesis cites SPES: A Symbolic Approach to Proving Query Equivalence Under Bag Semantics
- Automated Discovery of Test Oracles for Database Management Systems Using LLMs cites ParSEval: Plan-aware Test Database Generation for SQL Equivalence Evaluation
Cited by top-tier papers7
- SpotIt: Evaluating Text-to-SQL Evaluation with Formal VerificationRocky Klopfenstein, Yang He, Andrew Tremante, Yuepeng Wang et al.ICLR 2026 · 6 citations
- Proving Cypher Query EquivalenceLei Tang, Wensheng Dou, Yingying Zheng, Lijie Xu et al.ICDE 2025 · 3 citations
- ParSEval: Plan-aware Test Database Generation for SQL Equivalence EvaluationChunyu Chen, Zhengjie Miao, Yong Zhang, Jiannan WangVLDB 2025 · 1 citation
- Optimal Predicate Pushdown SynthesisRobert Zhang, Eric Hayden Campbell, Dixin Tang, Isil DilligPLDI 2026 · 1 citation
- Automated Discovery of Test Oracles for Database Management Systems Using LLMsQiuyang Mang, Runyuan He, Suyang Zhong, Xiaoxuan Liu et al.SIGMOD 2026 · 1 citation
Builds on1
Related papers
- VeriEQL: Bounded Equivalence Verification for Complex SQL Queries with Integrity ConstraintsYang He, Pinhan Zhao, Xinyu Wang, Yuepeng WangOOPSLA 2024 · 12 citations
- Proving Query Equivalence Using Linear Integer ArithmeticHaoran Ding, Zhaoguo Wang, Yicun Yang, Dexin Zhang et al.SIGMOD 2024 · 20 citations
- Query Weak Equivalence and its Verification in Analytical DatabasesJinguo You, Wanting Fu, Yuxuan Wang, Peilei He et al.ICDE 2025 · 1 citation
- Equivalence-Invariant Algebraic Provenance for Hyperplane Update QueriesPierre Bourhis, Daniel Deutch, Yuval MoskovitchSIGMOD 2020 · 6 citations
- Translating canonical SQL to imperative code in CoqVéronique Benzaken, Evelyne Contejean, Mohammed Houssem Hachmaoui, Chantal Keller et al.OOPSLA 2022 · 3 citations
