NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Extending Relational Query Processing with ML Inference

Konstantinos Karanasos, Matteo Interlandi, Fotis Psallidas, Rathijit Sen, Kwanghyun Park, Ivan Popivanov, Doris Xin, Supun Nakandala, Subru Krishnan, Markus Weimer, Yuan Yu, Raghu Ramakrishnan, Carlo Curino

Abstract

Raven is a system that integrates machine learning (ML) inference directly into the core of a relational database management system (RDBMS). By utilizing a unified intermediate representation for both SQL and ML, Raven enables "cross-optimizations" that simplify models based on data filters and vice versa. Experimental results demonstrate performance gains of up to 24× over traditional decoupled approaches.

Introduction

In modern enterprise environments, data typically resides in relational databases (RDBMS), while machine learning workflows are executed in external frameworks such as Scikit-learn or PyTorch. This separation imposes a significant "data tax": to perform model scoring, data must be exported from the database, transformed, and ingested by a separate runtime. This process is inherently slow, introduces security risks by moving data outside protected boundaries, and complicates model versioning and auditing.

Raven addresses a fundamental question: Can in-database scoring match or outperform dedicated ML frameworks? By treating ML as a first-class citizen within the database engine, Raven overcomes the "black box" limitation of current systems, allowing the database optimizer to understand and optimize the combined data-and-ML pipeline.

System Architecture

Raven is integrated into SQL Server and relies on three architectural pillars to bridge the gap between relational algebra and machine learning:

  1. Unified Intermediate Representation (IR): Raven translates SQL queries and ML pipelines (typically authored in Python) into a single graph. This graph integrates Relational Algebra for data operations and Linear Algebra for ML operations.
  2. Static Analysis: A static analyzer parses Python scripts and SQL commands to construct the unified IR. While complex loops may be wrapped in "black box" User Defined Functions (UDFs), Raven can translate most standard ML operations from libraries like Scikit-learn or NumPy into its native IR.
  3. Cross-Optimizations: This core innovation allows the system to perform optimizations that are impossible in decoupled systems. For instance, Raven can "push" data filters into the model or "pull" model requirements into the data fetch layer.
Figure 1: The Raven end-to-end pipeline, from SQL/Python input to unified IR and optimized execution plan.

Optimization Strategies

By breaking the "black box" of ML models, Raven enables several advanced optimization techniques:

  • Predicate-based Pruning: If a SQL query filters for a specific subset (e.g., "pregnant patients"), Raven can prune branches of a decision tree that are irrelevant to that subset, simplifying the computational overhead.
  • Model-Projection Pushdown: Raven identifies zero-weight features in sparse models (often resulting from L1-regularization) and instructs the database to skip fetching those columns, reducing I/O and unnecessary joins.
  • Neural Network (NN) Translation: Raven can transform classical models, such as Random Forests, into equivalent Neural Networks to leverage highly optimized execution engines like the ONNX Runtime.

Evaluation and Results

The researchers evaluated Raven using two primary scenarios: predicting hospital length of stay and predicting flight delays using a 10-million-tuple Kaggle dataset.

Key results include:

  • Native Integration: Simply embedding the ONNX Runtime within SQL Server to avoid data movement provided up to a 5.5× speedup.
  • Cross-Optimizations: When Raven applied unique optimizations like pruning and inlining, it achieved up to a 24× speedup compared to unoptimized inference.
  • Scalability: Raven outperformed standalone ML runtimes by 5× on large datasets by leveraging SQL Server’s mature multi-threaded scanning and parallelization capabilities.
Figure 6: Performance comparison showing the impact of SQL inlining and pruning on inference time compared to scikit-learn.

Conclusion and Future Work

Raven demonstrates that deep integration of ML into the RDBMS can yield massive performance benefits. Future research directions include the development of a full cost-based optimizer to replace current heuristic rules, deeper integration of hardware acceleration (GPUs/FPGAs) into database resource management, and the exploration of "lossy" optimizations that trade minimal accuracy for significant speed gains.

Summary updated

BibTeX
@inproceedings{karanasos2020extending,
  author = {Konstantinos Karanasos and Matteo Interlandi and Fotis Psallidas and Rathijit Sen and Kwanghyun Park and Ivan Popivanov and Doris Xin and Supun Nakandala and Subru Krishnan and Markus Weimer and Yuan Yu and Raghu Ramakrishnan and Carlo Curino},
  title = {{Extending Relational Query Processing with ML Inference}},
  booktitle = {CIDR},
  year = {2020},
  url = {https://openreview.net/forum?id=mwDndmV7pUh},
}
Figure