LEO - DB2's LEarning Optimizer

Michael Stillger, Guy M. Lohman, Volker Markl, Mokhtar Kandil

Very Large Data Bases · 2001 · 305 citations · 14 references

Concepts

TL;DR

Modern DBMS optimizers rely on cost models that depend on accurate row‑count estimates derived from database statistics, which may be inaccurate for complex queries. This paper introduces LEO, DB2’s LEarning Optimizer, to repair incorrect statistics and cardinality estimates in query execution plans. LEO monitors executed queries, compares optimizer estimates with actual results at each QEP step, and computes adjustments to cost estimates and statistics that can be applied online or offline, incrementally or in batches, and to any operation such as joins, predicates, DISTINCT, and GROUP‑BY. LEO’s feedback loop improves optimizer accuracy, and performance tests on a 10 GB TPCH dataset show negligible monitoring overhead while yielding orders‑of‑magnitude response time gains.

Abstract

Most modern DBMS optimizers rely upon a cost model to choose the best query execution plan (QEP) for any given query. Cost estimates are heavily dependent upon the optimizer’s estimates for the number of rows that will result at each step of the QEP for complex queries involving many predicates and/or operations. These estimates rely upon statistics on the database and modeling assumptions that may or may not be true for a given database. In this paper we introduce LEO, DB2's LEarning Optimizer, as a comprehensive way to repair incorrect statistics and cardinality estimates of a query execution plan. By monitoring previously executed queries, LEO compares the optimizer’s estimates with actuals at each step in a QEP, and computes adjustments to cost estimates and statistics that may be used during future query optimizations. This analysis can be done either on-line or off-line on a separate system, and either incrementally or in batches. In this way, LEO introduces a feedback loop to query optimization that enhances the available information on the database where the most queries have occurred, allowing the optimizer to actually learn from its past mistakes. Our technique is general and can be applied to any operation in a QEP, including joins, derived results after several predicates have been applied, and even to DISTINCT and GROUP-BY operators. As shown by performance measurements on a 10 GB TPCH data set, the runtime overhead of LEO’s monitoring is insignificant, whereas the potential benefit to response time from more accurate cardinality and cost estimates can be orders of magnitude.

References

14