Skip to main content
QUICK REVIEW

[Paper Review] Adaptive Cardinality Estimation

О. П. Иванов, Sergey Bartunov|arXiv (Cornell University)|Nov 22, 2017
Advanced Database Systems and QueriesComputer Science22 references9 citations
TL;DR

This paper proposes adaptive cardinality estimation using machine learning to improve cost-based query optimization in relational databases. By leveraging execution statistics from previously run queries, the method dynamically refines cardinality predictions, reducing estimation errors and improving query performance by up to several dozen times on complex queries.

ABSTRACT

In this paper we address cardinality estimation problem which is an important subproblem in query optimization. Query optimization is a part of every relational DBMS responsible for finding the best way of the execution for the given query. These ways are called plans. The execution time of different plans may differ by several orders, so query optimizer has a great influence on the whole DBMS performance. We consider cost-based query optimization approach as the most popular one. It was observed that cost-based optimization quality depends much on cardinality estimation quality. Cardinality of the plan node is the number of tuples returned by it. In the paper we propose a novel cardinality estimation approach with the use of machine learning methods. The main point of the approach is using query execution statistics of the previously executed queries to improve cardinality estimations. We called this approach adaptive cardinality estimation to reflect this point. The approach is general, flexible, and easy to implement. The experimental evaluation shows that this approach significantly increases the quality of cardinality estimation, and therefore increases the DBMS performance for some queries by several times or even by several dozens of times.

Motivation & Objective

  • Address the critical problem of inaccurate cardinality estimation in cost-based query optimization, which severely impacts database performance.
  • Overcome the limitations of traditional methods like histogram-based estimation and the clause independence assumption in System R.
  • Develop a flexible, general-purpose method that adapts to workload and data changes using machine learning.
  • Improve query optimizer accuracy and reduce performance degradation caused by poor cardinality estimates.

Proposed method

  • Use execution statistics from previously executed queries as training data to train machine learning models for cardinality prediction.
  • Formulate cardinality estimation as a supervised machine learning problem, where features are derived from query predicates and table statistics.
  • Apply k-nearest neighbors (k-NN) as the core learning algorithm, with a fixed-memory implementation to handle large-scale, streaming query workloads.
  • Construct feature space based on column selectivity, join conditions, and predicate structures to capture data dependencies.
  • Integrate the model into the query optimizer to re-estimate cardinalities during plan selection, improving cost model accuracy.
  • Support dynamic adaptation by retraining or updating the model with new execution statistics, especially from interrupted or poorly performing plans.

Experimental results

Research questions

  • RQ1To what extent do current cost-based query optimizers fail due to poor cardinality estimation, especially under correlated or dependent predicates?
  • RQ2Can machine learning models trained on historical query execution statistics significantly improve cardinality estimation accuracy?
  • RQ3How does the performance of the proposed adaptive method compare to traditional statistics-based approaches on complex, real-world workloads?
  • RQ4What are the key design trade-offs in building a scalable, adaptive cardinality estimation system for industrial DBMS?
  • RQ5Can query re-optimization based on interrupted execution statistics further improve learning and plan quality?

Key findings

  • Standard query optimizers based on the clause independence assumption often select plans that are orders of magnitude slower than optimal, especially for complex queries.
  • The proposed adaptive cardinality estimation method reduces cardinality estimation errors and enables selection of plans much closer to optimal, achieving speedups of up to several dozen times on complex queries.
  • The method performs particularly well on complex queries, where traditional optimizers fail due to incorrect selectivity estimates, even though the queries are not computationally expensive.
  • Experimental evaluation on TPC-H, TPC-DS, JOB, and StrongCor benchmarks confirms significant performance gains, with the largest improvements observed in high-complexity query workloads.
  • Using statistics from partially executed or interrupted queries—especially those with severe cardinality underestimation—can accelerate model learning and avoid full execution of suboptimal plans.
  • The k-NN-based approach with fixed-memory storage enables scalable, real-time adaptation to changing data and workloads, though dynamic adaptation mechanisms remain an open research challenge.

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.