Reinforcement Learning with Tree-LSTM for Join Order Selection
Xiang Yu, Guoliang Li, Chengliang Chai, Nan Tang
Abstract
Join order selection (JOS) -the problem of finding the optimal join order for an SQL query -is a primary focus of database query optimizers. The problem is hard due to its large solution space. Exhaustively traversing the solution space is prohibitively expensive, which is often combined with heuristic pruning. Despite decades-long effort, traditional optimizers still suffer from low scalability or low accuracy when handling complicated SQL queries. Recent attempts using deep reinforcement learning (DRL), by encoding join trees with fixed-length handtuned feature vectors, have shed some light on JOS. However, using fixed-length feature vectors cannot capture the structural information of a join tree, which may produce poor join plans. Moreover, it may also cause retraining the neural network when handling schema changes (e.g., adding tables/columns) or multialias table names that are common in SQL queries.
In this paper, we present RTOS, a novel learned optimizer that uses Reinforcement learning with Tree-structured long shortterm memory (LSTM) for join Order Selection. RTOS improves existing DRL-based approaches in two main aspects: (1) it adopts graph neural networks to capture the structures of join trees; and (2) it well supports the modification of database schema and multi-alias table names. Extensive experiments on Join Order Benchmark (JOB) and TPC-H show that RTOS outperforms traditional optimizers and existing DRL-based learned optimizers. In particular, the plan RTOS generated for JOB is 101% on (estimated) cost and 67% on latency (i.e., execution time) on average, compared with dynamic programming that is known to produce the state-of-the-art results on join plans.
Example 1 shows that, join trees with different join orders may be encoded into the same feature vector using existing learners; that is, they only consider the static information (such as tables and columns) of a join, without being able to capture the structural information of a join tree. Intuitively, a better learner should also understand different structural information of different join trees.
Our Methodology. Based on the above observation, we present RTOS, a novel learned optimizer using tree-structured long short-term memory (Tree-LSTM) [37]. RTOS trains a DRL model for JOS, which can automatically improve future JOS by learning from previously executed queries.
Tree-LSTM is one kind of graph neural networks (GNNs).
1297
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext cdc71170-c145-4b62-a8d5-5c43ef3b08aaCited by top-tier papers54
- An End-to-End Learning-based Cost EstimatorJi Sun, Guoliang LiVLDB 2020 · 251 citations
- Are We Ready For Learned Cardinality Estimation?Xiaoying Wang, Changbo Qu, Weiyuan Wu, Jiannan Wang et al.VLDB 2021 · 156 citations
- QueryFormer: A Tree Transformer Model for Query Plan RepresentationYue Zhao, Gao Cong, Jiachen Shi, Chunyan MiaoVLDB 2022 · 117 citations
- Lero: A Learning-to-Rank Query OptimizerRong Zhu, Wei Chen, Bolin Ding, Xingguang Chen et al.VLDB 2023 · 102 citations
- Learned Cardinality Estimation: A Design Space Exploration and A Comparative EvaluationJi Sun, Jintao Zhang, Zhaoyan Sun, Guoliang Li et al.VLDB 2022 · 90 citations
Builds on1
Related papers
- LOGER: A Learned Optimizer towards Generating Efficient and Robust Query Execution PlansTianyi Chen, Jun Gao, Hedui Chen, Yaofeng TuVLDB 2023 · 54 citations
- Efficient Join Order Selection Learning with Graph-based RepresentationJin Chen, Guanyu Ye, Yan Zhao, Shuncheng Liu et al.KDD 2022 · 27 citations
- FOSS: A Self-Learned Doctor for Query OptimizerKai Zhong, Luming Sun, Tao Ji, Cuiping Li et al.ICDE 2024 · 5 citations
- GLO: Towards Generalized Learned Query OptimizationTianyi Chen, Jun Gao, Yaofeng Tu, Mo XuICDE 2024 · 7 citations
- Balsa: Learning a Query Optimizer Without Expert DemonstrationsZongheng Yang, Wei-Lin Chiang, Sifei Luan, Gautam Mittal et al.SIGMOD 2022 · 99 citations
