arXiv:2610.12692cs.DBOct 2026

Manuscript Offprint

arXiv:2610.12692

Distributed Datalog at Scale with Worst-Case Optimal Joins

Kunting Qi, Yihao Sun, Kristopher Micinski, Thomas Gilray, Sidharth Kumar

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Kunting Qi

University of Illinois Chicago

Chicago, IL, USA

kqi@uic.edu

Yihao Sun

Syracuse University

Syracuse, NY, USA

ysun67@syr.edu

Thomas Gilray

Washington State University

Pullman, WA, USA

thomas.gilray@wsu.edu

Kristopher Micinski

Syracuse University

Syracuse, NY, USA

kkmicins@syr.edu

Sidharth Kumar

University of Illinois Chicago

Chicago, IL, USA

sidharth@uic.edu

Abstract—Scalable logic-based analytics are frequently dominated by cyclic multi-way joins over large relational datasets. State-of-the-art systems evaluate these joins through chains of binary joins, incurring substantial overhead from large intermediate relations that must be materialized and redistributed across the network. Worst-Case Optimal Joins (WCOJ) offer a provably superior alternative by evaluating joins one variable at a time, eliminating intermediate blowup. However, existing WCOJ implementations target either shared-memory machines or one-shot, non-recursive queries on dataflow and big-data platforms, leaving WCOJ-based recursive evaluation on distributed-memory HPC systems an open problem. We present, to our knowledge, the first distributed-memory Datalog engine that uses WCOJ for recursive fixpoint evaluation. Our design builds on HyperCube partitioning, which hash-partitions relations along variable-aligned grid dimensions and replicates them along missing dimensions, and extends it from a single shuffle to iterative execution: in every semi-naïve iteration, only newly derived tuples are repartitioned and re-replicated, using MPI all-to-all collectives and per-dimension all-gathers over subcube communicators, while the same layout is reused across iterations so that all WCOJ intersections remain rank-local. We evaluate our system on the Aurora and Polaris leadership-class supercomputers at Argonne National Laboratory using graph mining and program analysis benchmarks, demonstrating strong scalability, outperforming state-of-the-art Datalog engines on most benchmarks, and characterizing how partition dimensionality trades runtime against memory feasibility.

I. INTRODUCTION

Large-scale relational reasoning underpins a broad class of high-impact workloads, from social network analysis and knowledge graph inference to cybersecurity threat detection and compiler pointer analysis [1]–[4]. At the core of these workloads are recursive conjunctive queries that iteratively derive new facts until a fixpoint is reached, placing sustained pressure on both memory capacity and compute throughput. As input datasets scale to billions of tuples, single-node systems quickly saturate available memory and stall on compute bottlenecks, making distributed execution across shared-nothing clusters a practical necessity. The central systems challenge is therefore to scale recursive relational query evaluation to high-performance clusters without incurring prohibitive data movement and inter-node communication costs.

These analytical workloads are naturally expressed in Datalog [5], a declarative logic programming language well suited to fixpoint computation over relational data. We illustrate Datalog through two representative analytics queries: the Triangle query from graph mining and the Peer Influence query from social network analysis. The Triangle query, Triangle (x,y,z)←R(x,y),S(y,z),T(z,x)(x,y,z) \leftarrow \mathrm{R}(x,y), \mathrm{S}(y,z), \mathrm{T}(z,x), is a non-recursive cyclic multi-way join over three relations. The Peer Influence query, by contrast, is recursive, with the head relation feeding back into the body, and models how influence propagates through densely connected communities within a network: Influenced (y)←Influenced(x)(y) \leftarrow \mathrm{Influenced}(x), Edge (x,y)(x,y), Edge (x,z)(x,z), Edge (z,y)(z,y). This rule states that a vertex yy becomes influenced if it is adjacent to an already-influenced vertex xx and the two share a common neighbor zz. Evaluating this rule requires finding such triangles by joining three occurrences of the Edge relation together with the Influenced relation, which forms a cyclic multi-way join.

Cyclic multi-way queries such as these are notoriously difficult for traditional distributed Datalog systems, which rely on binary joins. Evaluating a triangle two relations at a time forces the system to first compute all open two-hop paths. In dense graphs, these intermediate results explode, often growing asymptotically larger than both the final query output and the underlying graph itself (see Figure 1). In a parallel setting, this intermediate blowup is costly, as the system must fully materialize, repartition, and redistribute oversized intermediate relations across the network at each evaluation step. The problem is further exacerbated in recursive settings, where such expensive two-hop joins execute repeatedly across iterations, creating a persistent communication bottleneck that fundamentally limits cluster scalability.

Worst-Case Optimal Joins (WCOJ) [6], [7] address the intermediate explosion problem with provable guarantees. Rather than decomposing a multi-way join into a sequence of pairwise joins that materialize large intermediate relations, WCOJ evaluates the join one variable at a time through simultaneous set intersection across all participating relations. At each step, only tuples that are consistent with all join constraints are extended, and candidates that cannot participate in any final output tuple are pruned immediately, before they are ever materialized (see Figure 1). This attribute-at-a-time intersection ensures that no intermediate result ever exceeds the worst-case optimal bound established by the AGM inequality [8], structurally limiting intermediate data to its theoretical minimum. As a consequence, the massive shuffles and bandwidth bottlenecks incurred by repeated binary join materialization are eliminated, making WCOJ well-suited for communication-constrained distributed environments.

However, scaling WCOJ-based Datalog evaluation to a parallel system raises two challenges: how to partition the workload effectively across all processes, and how to support fixpoint iteration for recursive queries efficiently. Workload partitioning is inherently more complex in WCOJ than in binary join execution. Unlike binary joins, where partitioning decisions can be made independently for each relation pair, WCOJ must reconcile the partitioning requirements of all intersection variables simultaneously. For example, evaluating the Peer Influence query requires intersecting the x variable across every Edge and Influenced clause at once; a relation that does not carry a given variable cannot be partitioned on it, yet must still participate in the intersection, forcing either replication or remote data fetches. Efficient distributed WCOJ therefore demands a partition-aware execution model that jointly optimizes across all intersection variables, minimizes communication volume, and distributes the computational workload evenly across nodes. Equally important is support for recursive fixpoint iteration, where newly derived tuples from one iteration must be materialized and redistributed for use in the next, a step that again requires coordinated data movement across processes.

We address the workload partitioning challenge by developing a parallel WCOJ framework grounded in multidimensional hypercube partitioning [9], [10] (Section III). The core insight is that join variables naturally define dimensions of a logical process grid, and the number of variables selected for partitioning determines the dimensionality of that grid. With a single-variable partitioning scheme, the process space is divided along one dimension; relations carrying that variable are hash-partitioned across processes, while all other relations are fully replicated. In a two-variable scheme, processes are arranged in a 2D grid; relations carrying both variables are fully partitioned across the entire grid, relations carrying only one variable are partially partitioned along the corresponding dimension and require partial replication along the other, and relations carrying neither variable must be fully replicated. This pattern generalizes naturally to higher dimensions, with each additional variable typically reducing the replication of relations that carry it, at the cost of increased communication to coordinate the finer-grained partitioning. In this work, we demonstrate and evaluate partitioning schemes of up to three variables, corresponding to a 3D process grid. The choice of dimensionality exposes a tunable trade-off between replication overhead and communication volume, allowing the partitioning strategy to be adapted to the query structure and deployment scale (Section III-C).

To support iterative WCOJ execution, we adopt semi-naïve evaluation (Section IV), a standard database technique that restricts each iteration's input to the tuples newly derived in the previous iteration, avoiding redundant recomputation. Recursion is where our setting departs from prior distributed WCOJ systems [11]–[13], which evaluate a single conjunctive query after one round of data shuffling. In recursive evaluation, the newly derived tuples of every iteration must be materialized, repartitioned, and re-replicated to the processes that need them in the next iteration, which in general differ from the processes that generated them. We therefore reuse the same hypercube layout across all iterations and redistribute only the newly derived tuples, using MPI all-to-all collectives followed by per-dimension all-gathers over subcube communicators, so that every WCOJ intersection remains rank-local in every iteration. In summary, this paper makes the following contributions:

  1. We present, to our knowledge, the first distributed-memory Datalog engine that uses WCOJ for recursive semi-naïve fixpoint evaluation.

  2. We extend HyperCube partitioning [9], [10] from a single shuffle to iterative execution: each iteration repartitions and re-replicates only the newly derived tuples, using MPI_Alltoallv and per-dimension MPI_Allgatherv over subcube communicators, and reuses the same layout across iterations so that WCOJ intersections never require remote accesses.

  3. We evaluate the system on Polaris and Aurora, demonstrating strong scaling up to 2,048 processes and competitive performance against prior single-node and distributed Datalog systems, and we characterize how partition dimensionality trades runtime against memory feasibility.

Across the evaluated workloads, our system demonstrates strong scalability, achieving up to 14.3×14.3\times speedup on Polaris and 13.4×13.4\times on Aurora when scaling from 32 to 2,048 processes. On a single node, it is faster than established single-node engines on most of our recursive and cyclic query benchmarks, and it outperforms existing distributed Datalog engines on transitive closure. The remainder of this paper is organized as follows. Section II reviews the necessary background. Section III presents the workload partitioning strategy of our distributed WCOJ implementation, and Section IV describes how we extend it to the iterative setting. Section V reports scalability results on the Polaris and Aurora supercomputers and compares our system with existing engines. Section VI discusses related work, and Section VII concludes with directions for future work.

References (51)