Affiliation:
1. University of Washington, USA
Abstract
Every database system contains a query optimizer that performs query rewrites. Unfortunately, developing query optimizers remains a highly challenging task. Part of the challenges comes from the intricacies and rich features of query languages, which makes reasoning about rewrite rules difficult. In this paper, we propose a machine-checkable denotational semantics for SQL, the de facto language for relational database, for rigorously validating rewrite rules. Unlike previously proposed semantics that are either non-mechanized or only cover a small amount of SQL language features, our semantics covers all major features of SQL, including bags, correlated subqueries, aggregation, and indexes. Our mechanized semantics, called HoTT SQL, is based on K-Relations and homotopy type theory, where we denote relations as mathematical functions from tuples to univalent types. We have implemented HoTTSQL in Coq, which takes only fewer than 300 lines of code and have proved a wide range of SQL rewrite rules, including those from database research literature (e.g., magic set rewrites) and real-world query optimizers (e.g., subquery elimination). Several of these rewrite rules have never been previously proven correct. In addition, while query equivalence is generally undecidable, we have implemented an automated decision procedure using HoTTSQL for conjunctive queries: a well studied decidable fragment of SQL that encompasses many real-world queries.
Funder
Defense Advanced Research Projects Agency
National Science Foundation
U.S. Department of Energy
Publisher
Association for Computing Machinery (ACM)
Subject
Computer Graphics and Computer-Aided Design,Software
Reference63 articles.
1. Magic sets and other strange ways to implement logic programs (extended abstract)
2. B. Barras B. Grégoire A. Mahboubi and L. Théry. Coq reference manual chapter 25: The ring and field tactic families. https://coq.inria.fr/refman/Reference-Manual028. html. B. Barras B. Grégoire A. Mahboubi and L. Théry. Coq reference manual chapter 25: The ring and field tactic families. https://coq.inria.fr/refman/Reference-Manual028. html.
3. A Coq Formalization of the Relational Data Model
4. Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem
Cited by
14 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. QED: A Powerful Query Equivalence Decider for SQL;Proceedings of the VLDB Endowment;2024-07
2. Qr-Hint: Actionable Hints Towards Correcting Wrong SQL Queries;Proceedings of the ACM on Management of Data;2024-05-29
3. Graph-Attention-Network-Based Cost Estimation Model in Materialized View Environment;2023 IEEE 29th International Conference on Parallel and Distributed Systems (ICPADS);2023-12-17
4. GEqO: ML-Accelerated Semantic Equivalence Detection;Proceedings of the ACM on Management of Data;2023-12-08
5. Proving Query Equivalence Using Linear Integer Arithmetic;Proceedings of the ACM on Management of Data;2023-12-08