Skip to main content
QUICK REVIEW

[Paper Review] How I Learned to Stop Worrying and Love Re-optimization

Matthew Perron, Zeyuan Shang|arXiv (Cornell University)|Feb 21, 2019
Advanced Database Systems and QueriesComputer Science33 references6 citations
TL;DR

This paper proposes a dynamic re-optimization strategy to address persistent performance bottlenecks in database query optimization caused by inaccurate cardinality estimates. By re-planning long-running queries at runtime using updated statistics, the approach achieves 27% lower end-to-end latency on the top 20 slowest queries in the Join Order Benchmark—matching most of the benefit of perfect cardinality estimation with minimal changes to the optimizer.

ABSTRACT

Cost-based query optimizers remain one of the most important components of database management systems for analytic workloads. Though modern optimizers select plans close to optimal performance in the common case, a small number of queries are an order of magnitude slower than they could be. In this paper we investigate why this is still the case, despite decades of improvements to cost models, plan enumeration, and cardinality estimation. We demonstrate why we believe that a re-optimization mechanism is likely the most cost-effective way to improve end-to-end query performance. We find that even a simple re-optimization scheme can improve the latency of many poorly performing queries. We demonstrate that re-optimization improves the end-to-end latency of the top 20 longest running queries in the Join Order Benchmark by 27%, realizing most of the benefit of perfect cardinality estimation.

Motivation & Objective

  • To investigate why modern cost-based query optimizers still produce suboptimal plans despite decades of improvements.
  • To evaluate whether re-optimization offers a more practical path to performance improvement than refining cardinality estimation or plan enumeration.
  • To measure the impact of re-optimization on end-to-end query latency in a real-world benchmark workload.
  • To assess the risks and benefits of re-optimization in modern database systems.

Proposed method

  • The authors simulate a simple re-optimization scheme that triggers plan regeneration after a query has executed for a threshold duration.
  • They evaluate the approach on the Join Order Benchmark (JOB), comparing re-optimization against PostgreSQL’s default optimizer and perfect cardinality estimates (perfect-(n)).
  • Re-optimization is applied only to long-running queries, avoiding overhead on fast queries.
  • The study uses execution time relative to perfect-(17) as a baseline to measure improvement.
  • The authors analyze query execution time distributions and identify queries where re-optimization causes regressions.
  • They compare re-optimization with progressively better cardinality estimates (perfect-(n)) to assess diminishing returns.

Experimental results

Research questions

  • RQ1Can re-optimization significantly reduce end-to-end latency for poorly performing queries in a real-world benchmark?
  • RQ2How much of the benefit of perfect cardinality estimation can be achieved through re-optimization alone?
  • RQ3What are the performance risks of re-optimization, and which queries are most vulnerable to regression?
  • RQ4Does re-optimization remain beneficial when combined with increasingly accurate cardinality estimates?

Key findings

  • Re-optimization reduces the end-to-end latency of the top 20 longest-running queries in the Join Order Benchmark by 27%, achieving most of the benefit of perfect cardinality estimation.
  • Even with perfect estimates for joins of three or fewer tables (perfect-(3)), no improvement is seen on the slowest queries, indicating that better estimates alone are insufficient.
  • Re-optimization improves execution time for 45% of the benchmark’s queries, with the greatest gains on the longest-running ones.
  • The worst-case regression from re-optimization is over 100× worse than the original execution time, but this affects only a single query with an original runtime of ~10ms, so the overall impact is negligible.
  • Re-optimization combined with perfect-(5) estimates results in only a 6% performance degradation compared to perfect-(5) alone, indicating low risk at scale.
  • The study concludes that re-optimization is a more cost-effective path to performance improvement than striving for perfect cardinality estimation.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.