Native Machine Learning in Relational Databases

You are reading version 1 of this direction, frozen 2026-10-04. The latest version is version 2.

Version 1 of 2109 papers152 conceptsfrozen 2026-10-04

For decades, the worlds of data management and machine learning have lived on opposite sides of a high, expensive wall. Data lives in a Relational Database Management System (RDBMS), while models live in specialized environments like Python, PyTorch, or TensorFlow. To make a single prediction, data must be serialized, moved across a network, and loaded into a separate runtime—a process researchers call the "data tax."

A growing body of research aims to tear down this wall by integrating machine learning directly into the database engine. By treating inference and training as native database operations, these systems eliminate data movement and unlock optimizations that were previously impossible.

The Cost of Data Movement

In traditional workflows, the database is a "historian" that simply records what happened. To predict what will happen, an application must export data to an external ML server. As Anish Agarwal and Abdullah Alomar point out in their work on TSPS, this creates a "glue code" bottleneck where engineering effort is spent on data transformation rather than model tuning.

The performance penalty is even steeper. Alexandre E. Eichenberger and colleagues note that for small-scale models, the time spent moving data often dominates the actual computation time. By embedding deep learning inference directly into the RDBMS, systems can achieve significant speedups simply by maintaining data locality.

Breaking the Wall with Unified Representations

The most direct way to integrate ML is to treat a model as a first-class citizen within the database. Konstantinos Karanasos and the team behind Raven Extending Relational Query Processing with ML Inference achieved this by creating a unified intermediate representation (IR).

In Raven, both SQL operators (like JOIN or WHERE) and ML operators (like LinearRegression or DecisionTree) are translated into the same internal language. This allows the database optimizer to perform "cross-optimizations." For example, if a SQL query filters for "Age > 30," the engine can prune branches of a decision tree model that only apply to younger users before the model even runs. This deep integration can speed up inference by up to 24x.

Native Operators and Tensor Engines

Beyond simple integration, some researchers are reimagining the database engine itself. In NeurDB, Shaofeng Cai and others implement AI operations as native physical operators within the query executor. This allows the database to schedule ML tasks alongside traditional scans and joins, utilizing internal system metrics to optimize execution in real-time.

Taking this a step further, the Tensor Query Processor (TQP) Share the Tensor Tea compiles standard SQL operators into tensor programs. By "piggybacking" on ML frameworks like PyTorch, Yuki Asada and his team enable databases to run on GPUs and other hardware accelerators natively, treating data manipulation and model inference as parts of the same mathematical program.

Training at Scale Without Materialization

Training models on relational data often requires joining multiple tables into one massive "flat" table. This materialization step is a memory and I/O nightmare. Mahmoud Abo Khamis and the authors of FAQ-AI demonstrate that models like k-means and SVMs can be trained directly on the underlying relational structure. By using geometric data structures, they solve these queries in time proportional to the query complexity rather than the size of the expanded dataset.

For even more complex models, Yuxin Tang and Chris Jermaine have introduced frameworks for Auto-Differentiation of Relational Computations. By making relational algebra differentiable, they allow the database to perform the gradient-based updates necessary for deep learning, scaling to multi-terabyte datasets that would crash traditional ML tools.

Real-Time Forecasting and Self-Tuning

The ultimate goal of this research is the Predictive Database Management System (PDBMS). As envisioned by Mert Akdere and Ugur Çetintemel in The Case for Predictive Database Systems, these systems treat predictions as virtual tables.

Systems like tspDB implement this today by embedding predictive models as native indices. This allows a user to query a future timestamp as easily as a past one, with the database handling the underlying matrix factorization or statistical modeling automatically.

By moving the model to the data, we don't just get faster predictions; we get a system that can reason about its own future, adapt to changing data distributions, and provide a unified interface for the entire data lifecycle.

Papers in this version

Showing 60 of 109 papers.

History & citationVersion 2 · 2026-10-04

Current · Permanent link

  1. Version 2 (latest) · 2026-10-04 · 58 papers
  2. Version 1 · 2026-10-04 · 109 papers
Cite this direction

Latest version (a living page):

@misc{lacuna_in_database_machine_learning_ce3cf127,
  title = {in-database machine learning},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/in-database-machine-learning/rdr_ce3cf127f9ce4f8cad91fd2c0b2296ba},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-21},
}

This exact version (version 1, frozen text):

@misc{lacuna_native_machine_learning_in_relational_da_ce3cf127_v1,
  title = {Native Machine Learning in Relational Databases},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/native-machine-learning-in-relational-databases/rdr_ce3cf127f9ce4f8cad91fd2c0b2296ba/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-21},
}