For decades, the standard workflow for enterprise machine learning has involved a sharp architectural split. Data lives in a relational database management system (DBMS), but when it is time to train a model or run inference, that data must be extracted, serialized, and shipped over the network to an external framework like PyTorch or Scikit-learn.
As Ashvin Agrawal et al. point out in Cloudy with high chance of DBMS: a 10-year prediction for Enterprise-Grade ML, this "ETL tax" (Extract, Transform, Load) introduces massive latency, duplicates data, and compromises security governance. The emerging paradigm of in-database machine learning flips this relationship on its head: instead of moving data to the model, it embeds the model directly inside the database engine.
Compiling Inference into Relational Queries
To understand why this works, consider model inference. At its core, evaluating a trained model—whether a linear regression, a decision tree, or a neural network—is a series of mathematical transformations. If these transformations can be expressed in relational algebra, the database engine can execute them natively.
As demonstrated in Pushing ML Predictions Into DBMSs, libraries can translate entire machine learning pipelines (including featurization and model scoring) into standard SQL queries. By doing so, inference is executed as a native extension of relational algebra. This allows the database to apply its internal parallelization and query optimization strategies directly to model execution, matching or beating external frameworks by preserving data locality.
Furthermore, embedding inference into the query processor enables "cross-optimizations" that are impossible in decoupled systems. In Extending Relational Query Processing with ML Inference, Konstantinos Karanasos et al. present Raven, a system that uses a unified intermediate representation for both SQL and ML. If a SQL query filters data (e.g., WHERE age > 60), Raven can simplify the machine learning model dynamically based on that filter, or vice versa, achieving significant performance gains.
Factorized Learning: Training Without Joins
While inference is a natural fit for SQL, training models on relational data introduces a deeper challenge: the relational join explosion. Relational data is typically normalized across multiple tables (e.g., Users, Purchases, Products). Traditional ML frameworks require a single flat matrix, forcing developers to execute a massive JOIN query to materialize a giant intermediate table before training begins.
In-database machine learning bypasses this bottleneck entirely through factorized learning. In In-Database Factorized Learning, Hung Q. Ngo et al. demonstrate that the optimization algorithms used to train models (like gradient descent) do not actually need to see the fully expanded, materialized join table. Instead, they rely on data-dependent aggregates.
By exploiting relational structures like functional dependencies, the database can compute these aggregates directly over the normalized tables. As shown by Mahmoud Abo Khamis et al. in Functional Aggregate Queries with Additive Inequalities, models like $k$-means and Support Vector Machines (SVMs) can be trained in time sub-linear to the size of the join result. The execution time for gradient-based optimization becomes independent of the size of the materialized dataset, yielding orders-of-magnitude speedups.
AI-Native Database Kernels
Beyond compiling to standard SQL, researchers are rewriting the database kernel itself to treat AI operations as first-class citizens.
One approach is to extend relational engines with native support for iterative and matrix operations. In Recursive SQL and GPU-support for in-database machine learning, Maximilian E. Schüle extends the Umbra database system with automatic differentiation and JIT-compiled GPU kernels. By treating machine learning loops as a fixpoint iteration over relational algebra, the entire lifecycle—from preprocessing to neural network training—happens natively within the data store.
Taking this a step further, Apurva Gandhi et al. propose the Tensor Data Platform in The Tensor Data Platform: Towards an AI-centric Database System, which replaces the traditional relational core with a tensor abstraction powered by PyTorch. Similarly, Shaofeng Cai et al. introduce NeurDB in NeurDB: On the Design and Implementation of an AI-powered Autonomous Database, embedding AI operators directly into the query execution engine via a dedicated data streaming protocol over internal sockets.
By unifying data management and machine learning into a single engine, these systems eliminate cross-system communication bottlenecks, maximize data locality, and allow databases to automatically optimize both relational and tensor workloads simultaneously.
Key Foundational Work
Clustering gene expression data in SQL using locally adaptive metrics (2003) — contributed 2 concept elements to this direction.
Advances of the DBLearn System for Knowledge Discovery in Large Databases (1995) — contributed 1 concept elements to this direction.