arXiv:2608.25903cs.DBAug 2026

Manuscript Offprint

arXiv:2608.25903

MetaSieve: Faster Relational Deep Learning through SQL-Based Metapath Selection

Fahim Shahriar Khan, Ashraf Aboulnaga

ABSTRACT

Relational Deep Learning (RDL) is an effective approach to machine learning over multi-table relational databases. In RDL, a database is modeled as a graph in which each row is a node and each foreign-key relation is an edge, and a graph neural network (GNN) is trained on this graph. Training a GNN requires sampling a subgraph around every seed node in the training set, and the cost of training is largely determined by the size of these subgraphs. This paper aims to reduce subgraph size by leveraging the join and aggregation capabilities of relational database systems. We observe that sampled subgraphs are obtained by following metapaths composed of foreign-key links, and that many of these metapaths can be pruned without loss of accuracy. We present MetaSieve, a metapath selection layer that determines which metapaths to retain and which to prune. For each candidate metapath extension, MetaSieve computes statistics via SQL join and aggregation queries and evaluates the extension based on a novel scoring function that prefers lightweight but informative candidates. Metapaths whose scores fall below a threshold are deemed uninformative and pruned. Metapath selection in MetaSieve is lightweight since it relies only on database statistics and task labels, and it is independent of GNN parameters, so it integrates with diverse GNN architectures for classification and regression. Our evaluation on the RelBench benchmark with multiple GNN backbones shows that MetaSieve consistently reduces per-epoch training time by large margins while maintaining and often improving accuracy.

Code Availability:

https://github.com/lids-lab/metasieve

1 INTRODUCTION

Relational databases remain the default foundation for operational and analytical data, and much of the information used to train machine learning models is ultimately stored in relational database tables, connected by foreign-key relationships. Relational Deep Learning (RDL) has emerged as a practical way to learn directly from this multi-table structure by modeling the database as a heterogeneous graph and training a graph neural network (GNN) on this graph [9]. Each row in the database becomes a node in the graph whose type corresponds to its source table, and each foreign-key link becomes an edge whose type corresponds to its foreign-key type. By operating on the native relational structure, RDL sidesteps the need to flatten tables or hand-engineer features, and has shown strong results across multiple prediction tasks [31].

To train an RDL model for a specific task, the training data consists of rows from some table, termed seed rows, with a task-specific label associated with each row. For example, if the task is predicting customer churn, the seed rows are customers (identified by their customer id) and the labels indicate whether the customer

Ashraf Aboulnaga

University of Texas at Arlington

ashraf.aboulnaga@uta.edu

churned. These rows become the seed nodes in the RDL graph, and standard GNN architectures are trained by sampling a subgraph from the multi-hop neighborhood of each seed node and using the sampled subgraphs in standard backpropagation neural network training [5, 15, 17]. In the churn example, the sampled subgraph for each customer summarizes their behavior (e.g., purchases, reviews) and is used to train the GNN churn model.

The cost of GNN training depends heavily on the size and complexity of these sampled subgraphs. These subgraphs are typically sampled by randomly selecting neighbors at each hop, which in the RDL context amounts to following random foreign-key links. One way to improve sampling is to consider the metapaths being sampled. A metapath is a sequence of foreign-key edge types traversed from a seed node, and it is well established in heterogeneous graph learning that not all metapaths are equally useful [7, 23, 43].

Some metapaths are irrelevant to the task, others occur too rarely to provide a useful training signal, and still others are very frequent but noisy, increasing training cost without adding label-relevant information. An effective way to reduce the cost of GNN training is therefore to identify useful metapaths and restrict subgraph sampling to these metapaths, a problem known as metapath selection.

Metapath selection is particularly important for RDL because relational database schemas can be complex, inducing many diverse metapaths of varying usefulness, while large database instances increase the cost of sampling [1, 8]. In this paper, we introduce MetaSieve (Metapath Selection via SQL-Informed Evaluation of Valuable Extensions), a metapath selection technique for RDL that relies on two key ideas: (1) collecting metapath statistics using SQL queries, thereby leveraging a strength of the database system [18], and (2) identifying uninformative metapaths to prune (“sieve”) using principled scoring based on the statistics and task labels.

Prior work has shown that counting metapath occurrences is important for metapath selection, since the task label is often determined by aggregate evidence obtained from multiple occurrences of a metapath [8]. MetaSieve counts metapath occurrences using SQL queries that are simple, efficient, and do not require materializing the graph. For example, consider the rel-stack database from the RelBench benchmark [31], which represents the online activity of users on Stack Overflow, and consider the metapath user→posts→comments. We can compute the number of occurrences of this metapath for every seed user using a SQL aggregation query (e.g., COUNT(DISTINCT comments)). We can also compute more complex statistics such as the ratio of comments per post, which we term the rate, capturing “evidence per opportunity” (e.g., COUNT(DISTINCT comments) / COUNT(DISTINCT posts)). The queries used by MetaSieve are simple join-and-aggregation queries that can be executed efficiently, and we structure the computation so that each query is executed only once.

After collecting statistics for all candidate metapaths, MetaSieve treats metapath selection as a dependence-ranking problem and uses the mutual information (MI) between the statistics and the task label as a measure of metapath relevance [28], building on the standard view that MI captures general (including non-linear) dependence and is effective for lightweight feature scoring [2]. To penalize candidates that inflate the sampled neighborhood, MetaSieve makes its relevance measure cost-aware by favoring candidates that achieve high MI with low fanout. MetaSieve also penalizes metapaths infrequently observed in the data, and it combines these measures in a principled way to identify uninformative paths that can be avoided while sampling. Since MI applies to both discrete and continuous labels, the MetaSieve pipeline supports classification and regression tasks. Furthermore, the pipeline is agnostic to the GNN architecture, so it can be used with any GNN backbone.

We conduct experiments with multiple datasets from the RelBench benchmark [31], including the largest, recently added datasets, and we show that MetaSieve substantially outperforms the state-of-the-art MPS-GNN technique [8] in terms of preprocessing time, and speeds up training by up to an order of magnitude compared to random sampling and MPS-GNN. MetaSieve often leads to an improvement in accuracy in addition to reducing training time, especially with the state-of-the-art Relational Graph Transformer (RelGT) [5] GNN. These results hold for both classification and regression tasks.

In summary, our contributions are as follows:

• We introduce a task-specific metapath selection pipeline for RDL that computes metapath statistics efficiently using SQL queries, thereby avoiding graph materialization while directly leveraging relational structure.

• We propose a novel scoring function for pruning uninformative metapaths that uses mutual information as a lightweight proxy for relevance, penalizes large fanout to favor more compact subgraphs, and downweights infrequently observed metapaths.

• We evaluate the full pipeline on both node classification and node regression tasks from RelBench and show that the resulting metapath selection rules transfer across a wide range of GNN architectures, demonstrating the broad applicability of MetaSieve.