Abstract: The Join Order Selection (JOS) problem is a critical challenge in relational database optimization, where the goal is to find the most efficient sequence for joining tables. Traditional optimizers often rely on static heuristics that struggle with dynamic data, while early learned approaches face issues with representation collision and training instability. This paper introduces GTDD, a holistic Deep Reinforcement Learning (DRL) framework that addresses these hurdles by integrating multi-level representation learning—incorporating Graph Neural Networks (GNNs) and Tree-LSTMs—with a Dueling-DQN architecture. By utilizing curriculum learning and a normalized log-ratio reward function, GTDD achieves near-optimal performance on complex benchmarks like the Join Order Benchmark (JOB), significantly outperforming state-of-the-art learned optimizers in both plan quality and execution latency.
1. Introduction
In relational databases, the Join Order Selection (JOS) problem involves determining the optimal sequence to join multiple tables to minimize query execution cost. As the number of tables increases, the search space grows factorially, making the identification of the absolute cheapest plan an NP-hard task. While traditional optimizers use cost models and heuristics, they often fail to adapt to changing data distributions. Recent Deep Reinforcement Learning (DRL) approaches have attempted to learn these optimizations but are frequently hindered by two major issues: representation collision—where distinct join trees are mapped to similar vectors—and training instability caused by the massive variance in query costs.
2. The GTDD Framework
The GTDD framework tackles these challenges through a "holistic" design that combines advanced structural embeddings with a stable reinforcement learning architecture. The system iteratively builds a join tree by selecting actions from an action space defined by the query predicates.
2.1 Multi-Level Representation Learning
To prevent representation collision and capture the nuances of database structures, GTDD encodes information at four distinct levels:
- Column Level: Captures selectivity and predicates.
- Table Level: Uses Node2Vec on the database schema graph to embed structural relationships between tables before query processing.
- Query Level: Employs a Graph Neural Network (GNN) to understand the overall topology of the join graph.
- State Level: Utilizes a Tree-LSTM to represent the hierarchical structure of the join plan as it is being constructed, allowing the model to recursively summarize sub-plans.
2.2 Dueling-DQN and Training Strategies
GTDD adopts a Dueling-DQN architecture, which separates the estimation of "state value" from "action advantage." This helps the agent understand which join states are inherently better, regardless of the specific next action. To stabilize training, the framework employs curriculum learning, starting with simple queries (3–5 joins) and gradually introducing complex queries (up to 21 joins). Furthermore, a log-ratio reward function is used to normalize feedback, focusing the agent on relative improvement over a baseline rather than absolute costs.
3. Experimental Evaluation
The framework was evaluated on two primary benchmarks: the Join Order Benchmark (JOB), based on real-world IMDB data, and the industry-standard TPC-H benchmark.
3.1 Key Results
- Near-Optimal Performance: On the complex JOB dataset, GTDD achieved a Mean Relative Cost (MRC) of 1.063. Given that 1.0 represents the optimal plan found by exhaustive search, GTDD is nearly as effective as traditional dynamic programming but with significantly lower optimization overhead.
- Superiority Over State-of-the-Art: GTDD outperformed existing learned models like RTOS (MRC 1.22) and JOGGER (MRC 1.54). In terms of real-world execution latency, GTDD showed a 56% improvement over JOGGER.
- Convergence and Stability: GTDD stabilized its learning around 22,000 episodes, maintaining a steady performance level while competing models exhibited high volatility.
4. Conclusion and Future Work
GTDD demonstrates that combining schema-aware structural embeddings with hierarchical tree representations and stable DRL architectures can effectively solve the JOS problem. While the framework incurs higher training overhead due to its complex multi-level embeddings, its ability to generate near-optimal plans for large-scale queries marks a significant advancement in learned query optimization. Future research will focus on optimizing these representation methods to reduce training time without sacrificing structural fidelity.
Summary updated