Machine Learning Inference Pipeline Execution Using Pure SQL Based on Operator Fusion
Qingfeng Pan, Jiahe Zhi, Chenyang Zhang, Chen Xu, Zhao Zhang, Anita Shao, Guanglei Bao, Qiu Cui, Xiaowei Chen, Aoying Zhou
Abstract
Deploying machine learning (ML) inference pipelines in databases become increasingly prevalent in many applications. In order to avoid data transfer between the database and ML runtimes, existing ML2SQL frameworks parse ML pipelines to a graph consisting of ML operators and then translate it into pure SQL. Nevertheless, they typically rewrite the graph without operator fusion or only consider the fusion between certain operators such as StandardScaler and tree inference. However, there are various operators in ML pipelines, which have rich fusion opportunities between each other. To fully exploit operator fusion for graph rewriting, we classify widely used ML operators and design fusion rules driven by their characteristics. Moreover, rewriting the original graph by fusion rules produces candidate graphs that generate SQLs with different execution time. We employ an enumeration-based strategy to search for the graph with the lowest cost. However, this strategy may suffer from the combination explosion on search space for complex ML pipelines. To reduce this space, we propose a greedy-based strategy by exploiting the independence among ML operators. We implement a novel ML2SQL framework as a portable plugin for databases, namely Craftsman. Our experimental evaluations show that, in comparison to the existing approaches, Craftsman generates efficient SQL queries which achieves an average speedup of 2.9x on popular databases such as DuckDB.
Ask about this paper
Ask your agent about it.
Lune has read the top-tier papers around this one, so every answer names the papers it rests on.
Your agent calls
Lunesearch_papers
Free to start. No credit card required.
Terminal
Install the CLIlune papers get 1abacba1-746a-4c6d-a91c-b85226406c20Cited by top-tier papers1
Ask how each one uses itRelated papers
- InferDB: In-Database Machine Learning Inference Using IndexesRicardo Salazar-Díaz, Boris Glavic, Tilmann RablVLDB 2024 · 13 citations
- EncoderForge: Generating Efficient SQL for Encoders in Machine Learning Inference PipelinesQingfeng Pan, Qingyuan Jing, Chenyang Zhang, Jiahe Zhi et al.SIGMOD 2026
- Eliminating Redundant Feature Tests in Decision Tree and Random Forest Inference on SQL PredicatesMingxi Liu, Zhengyuan Ding, Chenyang Zhang, Qingfeng Pan et al.SIGMOD 2026
- Mitigating the Impedance Mismatch between Prediction Query Execution and Database EngineChenyang Zhang, Junxiong Peng, Chen Xu, Quanqing Xu et al.SIGMOD 2025 · 7 citations
- End-to-end Optimization of Machine Learning Prediction QueriesKwanghyun Park, Karla Saur, Dalitso Banda, Rathijit Sen et al.SIGMOD 2022 · 50 citations
