Language-Integrated Recursive Queries (Full Version)
Anna Herlihy, Amir Shaikhha, Anastasia Ailamaki, Martin Odersky

TL;DR
This paper introduces TyQL, a safe, recursive query language integrated with SQL, that ensures correctness and safety while achieving significant performance improvements for fixed-point computations.
Contribution
It proposes a formal calculus for deriving properties of recursive queries and implements TyQL, a Scala-based system that guarantees safety and performance in recursive database queries.
Findings
TyQL achieves no performance penalty compared to raw SQL.
TyQL provides a three-orders-of-magnitude speedup over non-recursive SQL.
The calculus automatically detects unsafe recursive queries.
Abstract
Performance-critical industrial applications, including large-scale program, network, and distributed system analyses, rely on fixed-point computations. The introduction of recursive common table expressions (CTEs) using the WITH RECURSIVE keyword in SQL:1999 extended the ability of relational database systems to handle fixed-point computations, unlocking significant performance advantages by allowing computation to move closer to the data. Yet with recursion, SQL becomes a Turing-complete programming language and, with that, unrecoverable safety and correctness risks. SQL itself lacks a fixed semantics, as the SQL specification is written in natural language, full of ambiguities that database vendors resolve in divergent ways. As a result, reasoning about the correctness of recursive SQL programs must rely on isolated mathematical properties of queries rather than wrestling a unified…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
