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 about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 8aa64cca-89f1-4289-a650-fa4e164dcf27Cited 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
