Balsa
The value network of a learned query optimizer: it predicts the cost or latency of a query plan.
Reinforcement learning and control · 80 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
At a glance
- Parameters
- 747.6K
- Operations
- 80
- Framework
- PyTorch
- Recurrent
- No
- Published
- SIGMOD 2022
- Cited by
- 103 (as of 26 October 2026)
- Authors
- Zongheng Yang, Wei-Lin Chiang, Sifei Luan and others
- Source
- GitHub: balsa-project/balsa
- License
- Apache-2.0
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Details
- Stable ID
- m14904
- Graph hash
- 3a7a3845baec51b13f6c9d97bf5f9e211f6978ab1716d56dc9915c6e820364e5
- Skeleton hash
- 51aee9c6ee7e321c555d19b7d7abb69251382a8c4c73bfa558d5eb652fd737ee
- Architecture hash
- 79bee40d3dfabf16eca35e10db4bbb51090e627cdc4aeb7d54411899deadedd5
- Diagram SHA-256
- d5d985ffa69709dd497f0c3502635457c63565640e9329c1abdc2043d09c126a
- TorchLens version
- 2.36.0
- Renderer
- graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
- Check
- Forward pass replayed in PyTorch
What it is
Balsa is a query optimizer built by deep reinforcement learning. It learns to optimize SQL queries by trial and error, and the paper sets out to show that this can be done without learning from an expert optimizer. Learning starts in a simple, environment-agnostic simulator and then continues safely in real execution.
The neural network at its center is a value network, which estimates the overall cost or latency of executing a query. The paper implements it as a simple tree convolution network and reports 0.7M parameters. Its inputs are a query and a plan; the query is encoded as a vector with one slot per table that holds the estimated selectivity of that table. With the learned value network, Balsa runs a best-first beam search to produce an execution plan for a query.
On the Join Order Benchmark the paper reports that Balsa matches two expert query optimizers, one open-source and one commercial, with two hours of learning, and outperforms them by up to 2.8× in workload runtime after a few more hours.
Key idea. Balsa learns a query optimizer by deep reinforcement learning, bootstrapping from a simple simulator and then learning safely in real execution, without learning from an expert optimizer.
- Balsa
- learned query optimizer
- query optimization
- deep reinforcement learning
- sim-to-real learning
- value network
- tree convolution
- Join Order Benchmark
- SQL
- query plan
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@misc{yang2022balsalearningqueryoptimizer,
title={Balsa: Learning a Query Optimizer Without Expert Demonstrations},
author={Zongheng Yang and Wei-Lin Chiang and Sifei Luan and Gautam Mittal and Michael Luo and Ion Stoica},
year={2022},
eprint={2201.01441},
archivePrefix={arXiv},
primaryClass={cs.DB},
doi={https://doi.org/10.1145/3514221.3517885},
url={https://arxiv.org/abs/2201.01441},
}