Optimizer Collection
This repository contains a curated collection of interesting and novel ideas for query optimization in relational database systems. Optimizer prototypes are implemented using the PostBOUND framework.
Think of the project as a playground or testbed to play around and explore different optimization techniques. Using PostBOUND's optimization pipelines, it is even possible to combine different optimization techniques, e.g. pessimistic join ordering with learned operator selection.
Optimizer Prototypes
| Optimizer | Description | Original Paper | Implementation |
|---|---|---|---|
| BAO | A reinforcement learning-based plan selector. | Marcus et al.: BAO: Making Learned Query Optimization Practical (SIGMOD'2021) 📄 Paper | 📁 Code |
| FASTgres | A supervised learning-based model for selecting optimizer hints | Woltmann et al.: FASTgres: Making Learned Query Optimizer Hinting Effective (VLDB'2023) 📄 Paper | 📁 Code |
| LpBound | An upper bound cardinality estimator based on lp-norms and linear programming. | Zhang et al.: LpBound: Pessimistic Cardinality Estimation using lp-Norms of Degree Sequences (SIGMOD'2025) 📄 Paper | 📁 Code |
| MSCN | A supervised, deep learning-based cardinality estimator. | Kipf et al.: Learned Cardinalities: Estimating Correlated Joins with Deep Learning. (CIDR'2019) 📄 Paper | 📁 Code |
| Naru | An unsupervised, deep autoregressive cardinality estimator for base tables. | Yang et al.: Deep Unsupervised Cardinality Estimation (VLDB'2020) 📄 Paper | 📁 Code |
| SafeBound | An upper bound cardinality estimator based on most common values statistics. | Deeds et al.: SafeBound: A Practical System for Generating Cardinality Bounds (SIGMOD'2023) 📄 Paper | 📁 Code |
| TONIC | A learned (but machine learning-free) operator selection algorithm for joins. | Hertzschuch et al.: Turbo-Charging SPJ Query Plans with Learned Physical Join Operator Selections. (VLDB'2022) 📄 Paper | 📁 Code |
| UES | An upper bound-driven, heuristic join order optimizer. | Hertzschuch et al.: Simplicity Done Right for Join Ordering. (CIDR'2021) 📄 Paper | 📁 Code |
Installation
The optimizer collection is available on PyPI. You can install it using pip or uv, or similar tools:
pip install postbound-playground
Usage
The different optimizers are available in as submodules of the postbound_extensions package.
Their usage is described in the corresponding README files, which can be found in the respective
submodules (see the table above).
For example, to the pessimistic UES join order optimizer can be combined with the TONIC operator selection algorithm like so:
import postbound as pb
import postbound_extensions as pbx
# Let's evaluate IMDB/JOB on Postgres
target_workload = pb.workloads.job()
target_database = pb.postgres.connect(".pg-connect-imdb.toml")
# Create our individual optimizer components
ues = pbx.ues.UesJoinOrdering(target_database)
tonic = pbx.tonic.TonicOperators.load_or_build(
"generated/tonic/job",
database=target_database,
sample_plans=target_workload.pick_random(13),
verbose=True
)
# Combine them into a complete optimizer
optimizer = (
pb.MultiStageOptimizationPipeline(target_database)
.use(ues)
.use(tonic)
.build()
)
# Start the benchmark
pb.bench.execute_workload(
target_workload,
on=optimizer,
query_preparation={"analyze": True, "prewarm": True},
name="playground-sample",
progressive_output="playground-sample.parquet",
logger="tqdm"
)
Contributing
The playground is a community-driven project. We welcome bug fixes and improvements as well as novel optimizer implementations. In fact, we are particularly happy about the latter. If you recently published a research paper on query optimization and want to make your implementation available for the broader community, please feel free to open a pull request or contact us!
If you noticed a bug in any part of the code base and do not have the resources to fix it yourself, feel free to open an issue. The playground is a living project and we will try to fix any issues as soon as possible.
This project is currently being maintained by Rico Bergmann (@rbergm). The current optimizer implementations have been created by the following people:
- BAO: provided by Rico Bergmann (@rbergm)
- FASTgres: provided by Kira Thiessat (@KiraThiessat)
- LpBound: provided by Rico Bergmann (@rbergm)
- MSCN: provided by Rico Bergmann (@rbergm)
- Naru: generated by Claude Opus 5.5 (Anthropic), supervised by Rico Bergmann (@rbergm)
- SafeBound: provided by Rico Bergmann (@rbergm)
- TONIC: provided by Rico Bergmann (@rbergm)
- UES: provided by Rico Bergmann (@rbergm)
Additional Utilities
In addition to the optimizer implementations, the playground also ships a number of utilities that deal with the "meta aspects" of query optimization, such as generating query workloads and gathering training data.
Currently, we provide the following utilities:
- the
postbound_extensions.samplermodule contains functions to generate SQL queries and execution plans - the
postbound_extensions.cebmodule implements the CEB workload sampler - the
postbound_extensions.preprocessingmodule contains utilities to featurize different data types into a numeric format and to cast values as written in SQL queries to their corresponding database types. - the
postbound_extensions.utilmodule gathers all kinds of utilities that did not really fit into any specific module. Best check out the exported symbols.
A detailed documentation is currently being written and will be available soon. In the meantime, it is probably best to just take a look at the exported symbols of each module. The members usually have a pretty extensive docstring that explains their purpose and usage, as well as related functions.
Metadata
Release files for PostBOUND-Playground 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| postbound_playground-0.1.0.tar.gz | 266.0 kB | Without provenance | Details for postbound_playground-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| postbound_playground-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for postbound_playground-0.1.0-py3-none-any.whl |
Total release size: 573.4 kB
Release files / postbound_playground-0.1.0.tar.gz
| Download URL | postbound_playground-0.1.0.tar.gz |
|---|---|
| Size | 266.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1b64eabeb934b18fb8634c063e063bed86afc53231915026354a9d64b1923adc
|
|
BLAKE2b-256 checksum How to use checksums |
6741c39896f28fac4e7e19a0293eb62ec87c8b7d5e5c9f4587e18d75eff7001a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / postbound_playground-0.1.0-py3-none-any.whl
| Download URL | postbound_playground-0.1.0-py3-none-any.whl |
|---|---|
| Size | 307.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
876e8b0ee9d45d56dbe8c7283bb0ace8d51e354dbbf5f54f9fdc29ee3641c895
|
|
BLAKE2b-256 checksum How to use checksums |
646c87a131e96b0afdce2bf2465c13347e53f5eea310657f607079c5dd4af2ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for PostBOUND-Playground 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.