All models

Bao

Tree-convolution network that predicts query plan performance so Bao can choose optimizer hints per query.

70 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (42 KB)

Open in a new tab

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
133.1K
Operations
70
Framework
PyTorch
Recurrent
No
Published
SIGMOD 2021
Authors
Ryan Marcus, Parimarjan Negi, Hongzi Mao and others
License
GPL-3.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m14907
Graph hash
a4c4dd073f8d861e9ceb497abb91df3f351f63cd7a071b49ddbd44dea04756cb
Skeleton hash
2bd4df1e13e1ff06e49ea086c142bea5924186d46e9be1ebf55612685fe3d2ad
Architecture hash
3b6e42d8c594576be5a88d89951abfdccbd480de8257ec8918df62669ab0471e
Diagram SHA-256
8461a97bf0fbc008b479acd5c3895f30389f983a6fa523a50517859bda307d64
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

Bao (the BAndit Optimizer) is a learned query optimizer that keeps a database's existing optimizer and steers it with per-query hints. The network on this page is its predictive model, a tree convolutional neural network that estimates how a candidate query plan will perform.

For each query, the underlying optimizer produces one plan per set of hints, and each plan is turned into a tree whose nodes are feature vectors. Each node vector holds a one-hot encoding of the operator type, cardinality and cost model information and, optionally, cache information. Tables and columns are left out of the encoding so that a schema change does not mean starting over. The tree passes through three stacked tree convolution layers, dynamic pooling flattens it into a single vector, and two fully connected layers map that vector to a performance prediction. The paper describes this architecture as similar to Neo's value prediction model.

Bao picks among the candidate plans with Thompson sampling, which balances exploring new plans against exploiting plans known to be fast. The released PostgreSQL prototype uses 5 arms (hint sets) by default. Its sliding-window training retrains the model every 25 queries.

Key idea. Bao combines a tree convolutional network with Thompson sampling to choose per-query hints for an existing query optimizer, learning from observed query performance.

  • Bao
  • Bandit Optimizer
  • BaoForPostgreSQL
  • learned query optimizer
  • query optimization
  • query hints
  • tree convolution
  • Thompson sampling
  • PostgreSQL
  • contextual bandit

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{marcus2020baolearningsteerquery,
      title={Bao: Learning to Steer Query Optimizers}, 
      author={Ryan Marcus and Parimarjan Negi and Hongzi Mao and Nesime Tatbul and Mohammad Alizadeh and Tim Kraska},
      year={2020},
      eprint={2004.03814},
      archivePrefix={arXiv},
      primaryClass={cs.DB},
      doi={https://doi.org/10.1145/3448016.3452838},
      url={https://arxiv.org/abs/2004.03814}, 
}