This paper revisits the connection between Datalog and relational databases, advocating recursive SQL as a backend for Datalog evaluation, and presents a compilation framework that translates Datalog programs, particularly those in the Linear Datalog fragment, into equivalent recursive SQL queries.
Abstract
Datalog is a declarative query language that has proven highly effective for expressing static program analyses. Although Datalog has deep roots in database theory, most recent advances have largely emerged from the programming languages and compiler communities, with systems such as Souffl\'e. In contrast, modern relational engines have made significant progress in optimizing recursive SQL. This paper revisits the connection between Datalog and relational databases, advocating recursive SQL as a backend for Datalog evaluation. We present a compilation framework that translates Datalog programs, particularly those in the Linear Datalog fragment, into equivalent recursive SQL queries. To bridge the gap between Datalog and SQL, the compiler routes every program through an intermediate language called Midlog. The compiler additionally recovers functional dependencies from the program and exposes them as schema keys, unlocking the engine's standard query optimizations. This approach enables existing database engines to execute a broad class of program analyses, outperforming the Souffl\'e engine by up to an order of magnitude on the Umbra backend. Umbra achieves a geometric-mean speedup of 5.46$\times$ at 8 threads, whereas DuckDB is competitive with Souffl\'e single-threaded and is slower at 8 threads (geometric-mean speedup of 0.68$\times$). Furthermore, the generated SQL is portable; it runs on seven database systems without any engine modification. Our results highlight what the relational engines require to fully support Datalog for large-scale program analysis.
Datalog has become a widely adopted language in program analysis, security, and data-intensive systems. However, debugging Datalog programs remains fundamentally challenging due to their declarative semantics, lack of explicit control flow, and massive scale of derived facts. Existing approaches, such as inspecting pro...
Jia-Shen Wei, Bao-Yuan Luo, Run-Shuo Xie et al.· 0 citations
Datalog underpins reasoning tasks such as program analysis, but its programs are hard to write. Existing synthesizers automate this task but require users to state their intent as input-output examples. Large language models (LLMs) suggest a more natural route, text-to-Datalog synthesis from a natural-language question...
Yuan Li, Han-Yun Jiang, Guo-Wei Tian et al.· 0 citations
This work builds on Rhyme, a declarative language whose object-notation syntax mirrors the structure of query results, and refine Rhyme's semantics for generator binding and missing values, allowing co-iteration, inner/outer joins, and nested-loop traversals to be expressed under different uses of generator symbols.
Ran Guo, Tiark Rompf· Proceedings of the VLDB Endo...· 0 citations
This work presents AutoSQL, a system that reconstructs SQL templates from Go ORM code that constructs a Code Index, a directed graph that captures structural dependencies between functions, types, and global variables as navigable edges and synthesizes SQL templates.
Jun-Song Pu, Yichen Li, Zhuang-Bin Chen et al.· 0 citations
Relational Database Management Systems (DBMSs) serve as foundational systems for data storage and management, supporting a rich variety of data types to specify storage formats and value ranges. These data types play a critical role in both data storage and computation. However, complex data computation operations (e.g...
Jiansen Song, Wensheng Dou, Ying-Ying Zheng et al.· Proceedings of the VLDB Endo...· 0 citations
SQL is the database community's success story in terms of language design. The key reason for its success is its declarativeness: it gives rise to optimizability, reducing the programmer's burden significantly. However, given the evolving complexity of problems to solve with query languages, our community needs to re-t...
Molham Aref, Leonid Libkin, Wim Martens· 0 citations
We use cookies to run the site and, with your consent, for analytics and to show ads.
See our Cookie Policy.