TL;DR
Tailwind is a non-invasive query planning framework that transparently injects highly specialized "query accelerators" into any relational database (RDBMS) without modifying its source code. By introducing a declarative abstraction called Abstract Logical Plans (ALPs) paired with tree-structured neural networks, Tailwind accurately predicts when a specialized accelerator will outperform the base database, delivering significant speedups on systems like Amazon Redshift and DuckDB.
What Problem Does This Paper Address?
General-purpose relational database management systems (RDBMSes) are designed to handle any arbitrary query, but this generality often leaves massive performance gains on the table. For specific workloads, purpose-built algorithms or precomputed data structures (which the authors call query accelerators) can execute sub-plans orders of magnitude faster than a standard database engine.
However, integrating these accelerators into an existing RDBMS is an engineering nightmare. It requires deep, invasive changes across the query optimizer, cost model, and execution engine. This "blast radius" makes custom optimizations impractical to maintain in open-source databases (like DuckDB) and completely impossible in closed-source, proprietary cloud data warehouses (like Amazon Redshift).
The authors introduce Tailwind to bridge this gap, allowing developers to plug specialized query accelerators into any RDBMS cleanly from the outside.
Methods
Tailwind operates as a database proxy layer sitting on top of an RDBMS. Its architecture relies on several novel components:
- Abstract Logical Plans (ALPs): A new declarative abstraction based on parameterized regular tree expressions. Instead of writing complex imperative code to check if an accelerator can handle a query, builders define the "shape" of supported logical sub-plans using an ALP template.
- Tree-Structured Neural Networks: Tailwind automatically compiles the tree structure of an ALP into a custom neural network architecture. This model learns to predict the accelerator's runtime based on query features (such as estimated cardinality and predicate selectivity) without needing to inspect or understand the accelerator's internal code.
- E-Graphs and Equality Saturation: To robustly match ALPs against incoming queries, Tailwind converts query plans into e-graphs. This allows Tailwind to identify acceleration opportunities even if the underlying database optimizer has reordered filters or joins.
- Two-Phase Planning:
- Offline: Tailwind uses a greedy search to select which stateful accelerator instances to precompute and store based on a user-defined space budget.
- Online: When a query arrives, Tailwind intercepts it, identifies matching sub-plans, uses its performance models to verify if the accelerator will actually provide a benefit, and transparently rewrites the query.
Datasets
The authors evaluated Tailwind using three distinct workloads:
- TPC-H (Scale Factor 100): A standard industry benchmark for analytical queries representing 100 GB of data.
- TPC-H-Plus: A newly introduced benchmark variant created by the authors. It merges fragments of standard TPC-H queries into 20 complex templates to create opportunities for multiple accelerators to trigger within a single query.
- SQLStorm Stack Overflow: A real-world dataset consisting of 240 GB of data from the Stack Overflow website, evaluated using a subset of 356 diverse queries.
Key Insights and Ideas
- Structure Provides Inductive Bias: Forcing accelerator builders to declare applicability via ALPs rather than arbitrary code provides a major machine learning advantage. The tree structure of the ALP maps perfectly to a tree-structured neural network, providing the ideal inductive bias to predict performance accurately with minimal training data (~10k samples).
- Cost Modeling is Mandatory: A naive strategy that blindly applies accelerators whenever they match often destroys performance. Hidden costs—such as cloud data transfer overheads or executing a "negated" query when the original predicate was already highly selective—can cause massive regressions. A precise cost model is essential to know when not to accelerate.
- RDBMS-Aware Tailoring: Tailwind automatically tailors its choices to the host database. For instance, it might leverage an index accelerator frequently on DuckDB (where in-process data transfer is practically free) but reject the exact same accelerator on Redshift because the network cost of moving intermediate tuples out of the cloud warehouse outweighs the execution speedup.
Key Results
Tailwind was evaluated using four baseline accelerators (Domain Negation, Cumulative Filtered Aggregates, Known Group-By, and Ordered Indexes) alongside two workload-specific ones (Top-k Pushdown and Badges Materialized Views).
- TPC-H: Tailwind achieved geomean speedups of 1.32× on Redshift and 1.38× on DuckDB.
- TPC-H-Plus: Tailwind delivered geomean speedups of 1.37× on Redshift and 1.76× on DuckDB. For complex queries where multiple accelerators were safely combined, it achieved localized speedups up to 4.6×–5.6×.
- SQLStorm: On real-world data, Tailwind yielded geomean speedups of 1.28× (Redshift) and 1.27× (DuckDB), primarily driven by pushing down top-k operations.
Limitations and Future Work
- Bulk-Write Dependency: Tailwind targets OLAP (analytical) environments characterized by bulk writes. Because accelerators rely on precomputed state, any data modification renders them stale. Tailwind currently routes queries back to the base RDBMS while rebuilding accelerators in the background. Implementing incremental state maintenance is left for future work.
- Upstream Predictor Errors: Tailwind's cost model relies on the host database's cardinality estimates. While the framework is robust up to a Q-error of 3.0, severe mispredictions by the underlying RDBMS can still lead Tailwind to make suboptimal routing choices.
- Synthesis Automation: While Tailwind automates the planning, matching, and cost-modeling of accelerators, humans must still write the accelerator code. The authors note that combining Tailwind with LLM-based query engine generators could eventually allow for entirely automated, end-to-end synthesis of custom database extensions.
Summary updated