Skip to main navigation menu Skip to main content Skip to site footer

Reinforcement Learning for Join Order Optimization in PostgreSQL: Query Rewriting and Evaluation on JOB and TPC-H Benchmarks

Abstract

Join order optimization is a critical combinatorial problem in query processing. This paper applies reinforcement learning (RL) techniques to the join order optimization task in PostgreSQL by implementing and evaluating three separate RL-based optimizers: Proximal Policy Optimization (PPO), Deep Q-Network (DQN), and Advantage Actor-Critic (A2C). Each method is trained on the Join Order Benchmark (JOB) and evaluated on both JOB and TPC-H workloads. Performance is compared against PostgreSQL’s default planner without join reordering (PG-Old) and the built-in PostgreSQL optimizer with reordering enabled (PG-Join). Results show that RL-based methods significantly reduce execution times compared to PG-Old and often perform on par with or better than PG-Join, especially for complex multi-join queries. Among the tested methods, PPO achieves the most consistent improvements, with up to 4.47× average speedup over PG-Old on JOB and measurable gains on TPC-H. These findings demonstrate the potential of reinforcement learning as a practical and adaptive approach to join order optimization in relational databases.

Keywords

Reinforcement Learning, Query Optimization, Join Order, TPC-H, PostgreSQL, Join Order Benchmark

PDF

References

  1. 13, Aug. 2018, doi: 10.14778/3229863.3236222.
  2. V. Mnih et al., “Playing Atari with Deep Reinforcement Learning,” Dec. 2013, [Online]. Available: http://arxiv.org/abs/1312.5602
  3. A. Brim, “Deep Reinforcement Learning Pairs Trading with a Double Deep Q-Network,” in 2020 10th Annual Computing and Communication Workshop and Conference (CCWC), IEEE, Jan. 2020, pp. 0222–0227. doi: 10.1109/CCWC47524.2020.9031159.
  4. V. Mnih et al., “Asynchronous Methods for Deep Reinforcement Learning,” Feb. 2016, [Online]. Available: http://arxiv.org/abs/1602.01783
  5. A. Mikhaylov, N. S. Mazyavkina, M. Salnikov, I. Trofimov, F. Qiang, and E. Burnaev, “Learned Query Optimizers: Evaluation and Improvement,” IEEE Access, vol. 10, pp. 75205–75218, 2022, doi: 10.1109/ACCESS.2022.3190376.
  6. Y. Gu, Y. Cheng, C. L. P. Chen, and X. Wang, “Proximal Policy Optimization With Policy Feedback,” IEEE Trans. Syst. Man Cybern. Syst., vol. 52, no. 7, pp. 4600–4610, Jul. 2022, doi: 10.1109/TSMC.2021.3098451.
  7. V. Leis et al., “Query optimization through the looking glass, and what we found running the Join Order Benchmark,” The VLDB Journal, vol. 27, no. 5, pp. 643–668, Oct. 2018, doi: 10.1007/s00778-017-0480-7.
  8. “TPC Benchmark TM H Standard Specification Revision 2.17.1 TPC BENCHMARK TM H,” 1993.
  9. R. Marcus and O. Papaemmanouil, “Towards a Hands-Free Query Optimizer through Deep Learning,” Dec. 2018, [Online]. Available: http://arxiv.org/abs/1809.10212

Downloads

Download data is not yet available.

Similar Articles

1-10 of 72

You may also start an advanced similarity search for this article.

Most read articles by the same author(s)