JoinGym: An Efficient Query Optimization Environment for Reinforcement Learning

Kaiwen Wang, Junxiong Wang, Yueying Li, Nathan Kallus, Immanuel Trummer +1 more
7/21/2023
cs.LG

Official code: kaiwenw/JoinGym (16 stars, Apache-2.0, last commit 2024-09-13).

Abstract

Join order selection (JOS) is the problem of ordering join operations to minimize total query execution cost and it is the core NP-hard combinatorial optimization problem of query optimization. In this paper, we present JoinGym, a lightweight and easy-to-use query optimization environment for reinforcement learning (RL) that captures both the left-deep and bushy variants of the JOS problem. Compared to existing query optimization environments, the key advantages of JoinGym are usability and significantly higher throughput which we accomplish by simulating query executions entirely offline. Under the hood, JoinGym simulates a query plan's cost by looking up intermediate result cardinalities from a pre-computed dataset. We release a novel cardinality dataset for $3300$ SQL queries based on real IMDb workloads which may be of independent interest, e.g., for cardinality estimation. Finally, we extensively benchmark four RL algorithms and find that their cost distributions are heavy-tailed, which motivates future work in risk-sensitive RL. In sum, JoinGym enables users to rapidly prototype RL algorithms on realistic database problems without needing to setup and run live systems.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

A lightweight RL environment for query optimization.

161PythonOct 17, 20232 years agoApache-2.0
reinforcement-learning

Similar Papers

Cite this paper

@article{wang2023joingym,
  title  = {JoinGym: An Efficient Query Optimization Environment for Reinforcement Learning},
  author = {Kaiwen Wang and Junxiong Wang and Yueying Li and Nathan Kallus and Immanuel Trummer and Wen Sun},
  year   = {2023},
  eprint = {2307.11704},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2307.11704v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2307.11704.svg)](https://codeofpaper.com/paper/2307.11704)

Discussion