Abstract
FOSS (a "plan-doctor") is a novel deep reinforcement learning (DRL) framework designed to improve database performance by iteratively refining suboptimal query plans generated by traditional optimizers. By combining a fine-grained refinement strategy with a simulated learning environment, FOSS addresses the efficiency-flexibility trade-off inherent in existing machine learning-based optimizers. Experimental results show that FOSS achieves up to an 8.33x speedup over PostgreSQL while converging significantly faster than previous state-of-the-art methods.
Introduction
Query optimizers are the core components of a database management system (DBMS), responsible for determining the most efficient execution path for SQL queries. However, traditional optimizers often rely on simplified mathematical models that struggle with accurate "cardinality estimation"—predicting the number of rows resulting from complex joins. This frequently leads to the selection of suboptimal execution plans.
Recent machine learning approaches have attempted to mitigate this through two primary paradigms: plan-constructors, which build plans from scratch but suffer from slow training times, and plan-steerers, which use coarse-grained hints but often miss optimal plans due to a restricted search space. FOSS introduces a "whitebox-expertise" approach, acting as a "doctor" that starts with a traditional plan and surgically repairs its weakest components.
System Architecture
The FOSS framework is built around three integrated components that facilitate rapid learning and precise optimization.
- The Planner (The Doctor): This DRL agent takes an initial plan from a traditional optimizer (e.g., PostgreSQL) and applies a sequence of refinement actions.
- Asymmetric Advantage Model (AAM): A specialized Transformer-based neural network that compares two query plans to predict which is superior without requiring actual execution. This bypasses the "latency wall"—the time-consuming process of running queries to obtain ground-truth performance data.
- Simulated Learner: Utilizing the AAM, FOSS creates a simulated environment where the agent can practice. This allows the generation of thousands of high-quality training experiences rapidly, statistically grounded in real-world performance.
Fine-Grained Refinement Strategy
Unlike plan-steerers that apply broad changes, FOSS operates with surgical precision. The agent can modify specific nodes within the plan tree, allowing for a much larger and more effective search space.
The agent's action space includes:
- Swapping Table Positions: Reordering joins to minimize intermediate result sizes.
- Overriding Join Methods: Specifically changing join algorithms (e.g., switching from a Hash Join to a Nested Loop Join) for individual nodes.
By starting with a plan that is already "90% correct," FOSS avoids the need to relearn basic database principles, focusing its learning capacity entirely on fixing the specific errors made by the traditional optimizer.
Evaluation and Results
FOSS was evaluated against three standard benchmarks: the Join Order Benchmark (JOB) (IMDb dataset), TPC-DS (10GB), and a large-scale Stack Overflow dataset (100GB).
- Performance Gains: FOSS achieved total latency speedups of 6.25x on JOB, 1.15x on TPC-DS, and 1.75x on Stack Overflow during training. On unseen test queries, the speedup reached as high as 8.33x compared to standard PostgreSQL.
- Training Efficiency: FOSS consistently outperformed other ML optimizers like Bao, Balsa, and HybridQO. Notably, it converged to high performance in approximately one hour on TPC-DS and Stack Overflow, whereas competing methods often required significantly more time or failed to scale to the 100GB workload.
Conclusion and Future Work
FOSS demonstrates that a refinement-based approach to query optimization is both more flexible than steering and more efficient than construction. By leveraging a simulated environment and fine-grained actions, it provides a scalable solution for modern database workloads. Future work includes expanding the framework to support "bushy" join trees and exploring its adaptability to highly dynamic datasets with frequent real-time updates.
Summary updated