Proceedings

Gradient-Based Join Ordering

Download BibTeX Cite

Proceedings of the Thirty-Fifth International Joint Conference on Artificial Intelligence. Main Track. Pages 2346-2354.

https://doi.org/10.24963/ijcai.2026/261

Abstract

Join ordering is the NP-hard problem of selecting the most efficient order in which to evaluate joins (conjunctive, binary operators) in a database query. Because query execution performance critically depends on this choice, join ordering lies at the core of query optimization. Traditional approaches cast this problem as a discrete combinatorial search over binary trees guided by a cost model, but they have trade-offs between effectiveness and efficiency.

We show that when the cost model is differentiable, query plans can be continuously relaxed into a soft adjacency matrix that represents a superposition of plans. This continuous relaxation, combined with differentiable constraints that enforce plan validity, enables a gradient-based search for low-cost plans within this relaxed space. Using a Graph Neural Network as the cost model, we demonstrate that this gradient-based approach can find comparable and even lower-cost plans compared to traditional discrete search methods on two different graph datasets. Furthermore, we empirically show that the runtime of this approach scales better than discrete search algorithms. We believe this first step towards gradient-based join ordering can lead to more effective and efficient query optimizers in the future.

  1. [Acosta et al., 2025] Maribel Acosta, Chang Qin, and Tim Schwabe. Neuro-Symbolic Query Optimization in Knowl- edge Graphs. IOS Press, March 2025.
  2. [Aytimur et al., 2025] Mehmet Aytimur, Theodoros Chon- drogiannis, and Michael Grossniklaus. Space: Cardi- nality estimation for path queries using cardinality-aware sequence-based learning. Proceedings of the ACM on Management of Data, 3(3):1-26, 2025.
  3. [Casals et al., 2023] Daniel Casals, Carlos Buil-Aranda, and Carlos Valle. SPARQL query execution time prediction using deep learning. Semantic Web, 2023.
  4. [Chen et al., 2022] Jin Chen, Guanyu Ye, Yan Zhao, Shuncheng Liu, Liwei Deng, Xu Chen, Rui Zhou, and Kai Zheng. Efficient join order selection learning with graph- based representation. In Aidong Zhang and Huzefa Rang- wala, editors, KDD '22: The 28th ACM SIGKDD Confer- ence on Knowledge Discovery and Data Mining, Washing- ton, DC, USA, August 14 -18, 2022, pages 97-107. ACM, 2022.
  5. [Chen et al., 2023] Tianyi Chen, Jun Gao, Hedui Chen, and Yaofeng Tu. LOGER: A learned optimizer towards gen- erating efficient and robust query execution plans. Proc. VLDB Endow., 16(7):1777-1789, 2023.
  6. [Cluet and Moerkotte, 1995] Sophie Cluet and Guido Mo- erkotte. On the complexity of generating optimal left-deep processing trees with cross products. In Georg Gottlob and Moshe Y. Vardi, editors, Database Theory -ICDT'95, 5th International Conference, Prague, Czech Republic, Jan- uary 11-13, 1995, Proceedings, volume 893 of Lecture Notes in Computer Science, pages 54-67. Springer, 1995.
  7. [Cui and Zhu, 2021] Guofeng Cui and He Zhu. Differen- tiable synthesis of program architectures. In Marc'Aurelio Ranzato, Alina Beygelzimer, Yann N. Dauphin, Percy Liang, and Jennifer Wortman Vaughan, editors, Advances in Neural Information Processing Systems 34: Annual Conference on Neural Information Processing Systems 2021, NeurIPS 2021, December 6-14, 2021, virtual, pages 11123-11135, 2021.
  8. [Fegaras, 1998] Leonidas Fegaras. A new heuristic for op- timizing large queries. In Gerald Quirchmayr, Erich Schweighofer, and Trevor J. M. Bench-Capon, editors, Database and Expert Systems Applications, 9th Interna- tional Conference, DEXA '98, Vienna, Austria, August 24- 28, 1998, Proceedings, Lecture Notes in Computer Sci- ence, pages 726-735. Springer, 1998.
  9. [Grover et al., 2019] Aditya Grover, Eric Wang, Aaron Zweig, and Stefano Ermon. Stochastic optimization of sorting networks via continuous relaxations. In 7th Inter- national Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019. OpenRe- view.net, 2019.
  10. [Guo et al., 2005] Yuanbo Guo, Zhengxiang Pan, and Jeff Heflin. LUBM: A benchmark for OWL knowledge base systems. J. Web Semant., 3(2-3):158-182, 2005.
  11. [Hansen and Ostermeier, 2001] Nikolaus Hansen and An- dreas Ostermeier. Completely derandomized self- adaptation in evolution strategies. Evol. Comput., 9(2):159-195, 2001.
  12. [Kipf et al., 2018] Thomas N. Kipf, Ethan Fetaya, Kuan- Chieh Wang, Max Welling, and Richard S. Zemel. Neu- ral relational inference for interacting systems. In Jen- nifer G. Dy and Andreas Krause, editors, Proceedings of the 35th International Conference on Machine Learning, ICML 2018, Stockholmsmässan, Stockholm, Sweden, July 10-15, 2018, volume 80 of Proceedings of Machine Learn- ing Research, pages 2693-2702. PMLR, 2018.
  13. [Kipf et al., 2019] Andreas Kipf, Thomas Kipf, Bernhard Radke, Viktor Leis, Peter A. Boncz, and Alfons Kem- per. Learned cardinalities: Estimating correlated joins with deep learning. In 9th Biennial Conference on In- novative Data Systems Research, CIDR 2019, Asilomar, CA, USA, January 13-16, 2019, Online Proceedings. www.cidrdb.org, 2019. Link
  14. [Lecorvé et al., 2022] Gwénolé Lecorvé, Morgan Veyret, Quentin Brabant, and Lina M. Rojas Barahona. SPARQL- to-text question generation for knowledge-based conver- sational applications. In Yulan He, Heng Ji, Sujian Li, Yang Liu, and Chua-Hui Chang, editors, Proceedings of the 2nd Conference of the Asia-Pacific Chapter of the As- sociation for Computational Linguistics and the 12th In- ternational Joint Conference on Natural Language Pro- cessing (Volume 1: Long Papers), pages 131-147, Online only, November 2022. Association for Computational Lin- guistics.
  15. [Liu et al., 2019] Hanxiao Liu, Karen Simonyan, and Yim- ing Yang. DARTS: differentiable architecture search. In 7th International Conference on Learning Representa- tions, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019. OpenReview.net, 2019.
  16. [Marcus and Papaemmanouil, 2018] Ryan Marcus and Olga Papaemmanouil. Deep reinforcement learning for join order enumeration. In Rajesh Bordawekar and Oded Shmueli, editors, Proceedings of the First International Workshop on Exploiting Artificial Intelligence Techniques for Data Management, aiDM@SIGMOD 2018, Houston, TX, USA, June 10, 2018, pages 3:1-3:4. ACM, 2018.
  17. [Marcus et al., 2019] Ryan Marcus, Parimarjan Negi, Hongzi Mao, Chi Zhang, Mohammad Alizadeh, Tim Kraska, Olga Papaemmanouil, and Nesime Tatbul. Neo: A learned query optimizer. Proc. VLDB Endow., 12(11):1705-1718, 2019.
  18. [Mohanaraj et al., 2025] Abiram Mohanaraj, Matteo Lissan- drini, Katja Hose, et al. Planrgcn: Predicting sparql query performance. PROCEEDINGS OF THE VLDB ENDOW- MENT, 18(6):1621-1634, 2025.
  19. [Ng et al., 2020] Ignavier Ng, AmirEmad Ghassami, and Kun Zhang. On the role of sparsity and DAG con- straints for learning linear dags. In Hugo Larochelle, Marc'Aurelio Ranzato, Raia Hadsell, Maria-Florina Bal- can, and Hsuan-Tien Lin, editors, Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020. PostgreSQL Global Development Group, 2025] PostgreSQL Global Development Group. Postgresql 18.1 documentation: 61.3. genetic query optimization (geqo) in postgresql. https://www.postgresql.org/docs/18/ geqo-pg-intro.html, 2025. Accessed: 2026-01-02. Link
  20. [Prillo and Eisenschlos, 2020] Sebastian Prillo and Ju- lian Martin Eisenschlos. Softsort: A continuous relaxation for the argsort operator. In Proceedings of the 37th International Conference on Machine Learning, ICML 2020, 13-18 July 2020, Virtual Event, volume 119 of Proceedings of Machine Learning Research, pages 7793-7802. PMLR, 2020.
  21. [Qin and Acosta, 2025] Chang Qin and Maribel Acosta. Neuro-symbolic adaptive query processing over knowl- edge graphs. In International Semantic Web Conference, pages 253-270. Springer, 2025.
  22. [Schwabe and Acosta, 2024] Tim Schwabe and Maribel Acosta. Cardinality estimation over knowledge graphs with embeddings and graph neural networks. Proc. ACM Manag. Data, 2(1):44:1-44:26, 2024.
  23. [Selinger et al., 1979] Patricia G. Selinger, Morton M. As- trahan, Donald D. Chamberlin, Raymond A. Lorie, and Thomas G. Price. Access path selection in a relational database management system. In Philip A. Bernstein, editor, Proceedings of the 1979 ACM SIGMOD Interna- tional Conference on Management of Data, Boston, Mas- sachusetts, USA, May 30 -June 1, pages 23-34. ACM, 1979.
  24. [Steinbrunn et al., 1997] Michael Steinbrunn, Guido Mo- erkotte, and Alfons Kemper. Heuristic and randomized optimization for the join ordering problem. VLDB J., 6(3):191-208, 1997.
  25. [Sun and Li, 2019] Ji Sun and Guoliang Li. An end-to- end learning-based cost estimator. Proc. VLDB Endow., 13(3):307-319, 2019.
  26. [Swami, 1989] Arun N. Swami. Optimization of large join queries: Combining heuristic and combinatorial tech- niques. In James Clifford, Bruce G. Lindsay, and David Maier, editors, Proceedings of the 1989 ACM SIGMOD International Conference on Management of Data, Port- land, Oregon, USA, May 31 -June 2, 1989, pages 367- 376. ACM Press, 1989.
  27. [V et al., 2023] Jyothir S. V, Siddhartha Jalagam, Yann Le- Cun, and Vlad Sobal. Gradient-based planning with world models. CoRR, abs/2312.17227, 2023.
  28. [Vowels et al., 2023] Matthew J. Vowels, Necati Cihan Camgöz, and Richard Bowden. D'ya like dags? A survey on structure learning and causal discovery. ACM Comput. Surv., 55(4):82:1-82:36, 2023.
  29. [Wang et al., 2021] Xiaozhi Wang, Tianyu Gao, Zhaocheng Zhu, Zhengyan Zhang, Zhiyuan Liu, Juanzi Li, and Jian Tang. KEPLER: A unified model for knowledge embed- ding and pre-trained language representation. Trans. As- soc. Comput. Linguistics, 9:176-194, 2021.
  30. [Whitley et al., 1989] L Darrell Whitley, Timothy Stark- weather, and D'Ann Fuquay. Scheduling problems and traveling salesmen: The genetic edge recombination oper- ator. In Proceedings of the 3rd international conference on genetic algorithms, pages 133-140, 1989.
  31. [Xie et al., 2019] Sirui Xie, Hehui Zheng, Chunxiao Liu, and Liang Lin. SNAS: stochastic neural architecture search. In 7th International Conference on Learning Rep- resentations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019. OpenReview.net, 2019.
  32. [Xu et al., 2019] Keyulu Xu, Weihua Hu, Jure Leskovec, and Stefanie Jegelka. How powerful are graph neural net- works? In 7th International Conference on Learning Rep- resentations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019. OpenReview.net, 2019.
  33. [Yan et al., 2023] Zhengtong Yan, Valter Uotila, and Jiaheng Lu. Join order selection with deep reinforcement learning: Fundamentals, techniques, and challenges. Proc. VLDB Endow., 16(12):3882-3885, 2023.
  34. [Yu et al., 2020] Xiang Yu, Guoliang Li, Chengliang Chai, and Nan Tang. Reinforcement learning with tree-lstm for join order selection. In 36th IEEE International Confer- ence on Data Engineering, ICDE 2020, Dallas, TX, USA, April 20-24, 2020, pages 1297-1308. IEEE, 2020.
  35. [Zhao et al., 2021] Kangfei Zhao, Jeffrey Xu Yu, Hao Zhang, Qiyan Li, and Yu Rong. A learned sketch for subgraph counting. In Guoliang Li, Zhanhuai Li, Stratos Idreos, and Divesh Srivastava, editors, SIGMOD '21: In- ternational Conference on Management of Data, Virtual Event, China, June 20-25, 2021, pages 2142-2155. ACM, 2021.
  36. [Zhao et al., 2022] Yue Zhao, Gao Cong, Jiachen Shi, and Chunyan Miao. Queryformer: A tree transformer model for query plan representation. Proc. VLDB Endow., 15(8):1658-1670, 2022.
  37. [Zheng et al., 2018] Xun Zheng, Bryon Aragam, Pradeep Ravikumar, and Eric P. Xing. Dags with NO TEARS: con- tinuous optimization for structure learning. In Samy Ben- gio, Hanna M. Wallach, Hugo Larochelle, Kristen Grau- man, Nicolò Cesa-Bianchi, and Roman Garnett, editors, Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Sys- tems 2018, NeurIPS 2018, December 3-8, 2018, Montréal, Canada, pages 9492-9503, 2018.
  38. [Zhu et al., 2024] Rong Zhu, Lianggui Weng, Bolin Ding, and Jingren Zhou. Learned query optimizer: What is new and what is next. In Pablo Barceló, Nayat Sánchez-Pi, Alexandra Meliou, and S. Sudarshan, editors, Companion of the 2024 International Conference on Management of Data, SIGMOD/PODS 2024, Santiago, Chile, June 9-15, 2024, pages 561-569. ACM, 2024.

References were extracted automatically from the PDF and may contain errors.

Welcome Future Conferences AI Journal Division IJCAI Proceedings About IJCAI IJCAI Awards