Selectivity Estimation for Range Predicates using Lightweight Models

Anshuman Dutt, Chi Wang, Azade Nazi, Srikanth Kandula, Vivek R. Narasayya, Surajit ChaudhuriPVLDB 2019

TL;DR

Query optimizers rely on accurate selectivity estimates to choose efficient query execution plans. This paper proposes using lightweight regression models (neural networks and tree-based ensembles) to estimate the selectivity of multi-dimensional range predicates, outperforming traditional methods like Attribute Value Independence (AVI) and even more complex techniques in terms of both accuracy and speed.

What Problem Does This Paper Address?

Database query optimizers need to predict how many rows a query will return (selectivity) to decide the best way to execute it. For simple predicates on a single attribute, this is often done using histograms. However, for complex queries with multiple predicates on different attributes (multi-dimensional predicates), especially when those attributes are correlated, traditional methods like assuming attribute value independence (AVI) can lead to significant estimation errors. While more advanced techniques like multi-dimensional histograms or sampling exist, they often come with a high cost in terms of memory usage or estimation time, making them impractical for real-time query optimization. This paper aims to bridge this gap by developing lightweight models that can provide accurate and fast selectivity estimates for multi-dimensional range predicates.

Methods

The core idea is to frame selectivity estimation as a regression problem: learning a function that maps query predicates to their actual selectivity. The authors explore two main types of lightweight regression models:

  • Neural Networks (NNs): Standard feed-forward neural networks with ReLU activation functions in hidden layers.
  • Tree-based Ensembles: Specifically, random forests and gradient boosted trees (XGBoost).

To improve the performance of these models, two key design choices are introduced:

  1. Log-transformed labels: Instead of predicting the raw selectivity, the models predict the logarithm of the selectivity. This helps the models better handle the wide range of selectivity values and focus on relative errors, which are more relevant in this context.
  2. Heuristic estimators as features (CE features): The authors incorporate estimates from simpler, traditional methods like AVI, MinSel (minimum selectivity across predicates), and EBO (Exponential BackOff) as additional input features to the regression models. These features help the models differentiate between queries with similar range predicates but different actual selectivities, especially when attributes are correlated.

Datasets

The paper uses four real-world datasets for evaluation:

  • Forest: A dataset with 581,012 rows and 54 attributes, used with the first 10 numeric attributes.
  • Power: A dataset with over 2 million rows, measuring electric power consumption, using 7 numeric attributes.
  • Weather: A dataset with 3.4 million rows of daily climate records across 7 attributes.
  • Higgs: A scientific dataset with 11 million rows, using the last 7 high-level features.

The authors also construct query workloads by generating queries with varying dimensions (2 to 10) and two types of query center distributions: "random-centric" (uniform over the data domain) and "data-centric" (uniform over data tuples).

Key Insights and Ideas

  • Regression is a viable approach: Framing selectivity estimation as a regression problem, rather than relying solely on traditional histogram-based methods, offers a promising avenue for improved accuracy.
  • Lightweight models can be powerful: Neural networks and tree-based ensembles, when designed appropriately, can achieve high accuracy without requiring excessive model size or computational resources.
  • Log-transformation is crucial: Predicting the log of selectivity significantly improves the models' ability to handle the wide range of selectivity values and focus on relative errors.
  • Heuristic features provide "last mile" improvements: Incorporating estimates from simpler, traditional methods as features helps the regression models capture complex correlations and achieve higher accuracy, especially for correlated attributes.
  • Dimensionality is a challenge, but regression handles it better: While traditional methods struggle with increasing dimensionality, the proposed regression models show remarkable robustness, maintaining good accuracy even for higher-dimensional predicates.

Key Results

  • High Accuracy: The proposed lightweight regression models (NN and XGBoost with Log+CE features) achieve significantly higher accuracy (lower geometric mean q-error) compared to AVI, sampling, and even more advanced techniques like STHoles and KDE, especially for correlated attributes and higher dimensions.
  • Fast Estimation: The estimation time for the proposed models is comparable to or only slightly higher than AVI (within 1-2x), making them practical for query optimization. For instance, 16KB models are within 2x of AVI's 100µsec estimation time.
  • Compact Models: The models can achieve good accuracy with very small memory footprints (e.g., 16KB).
  • Robustness to Updates: The models are relatively robust to data updates, especially if 1D histograms are updated, allowing for efficient retraining or adaptation.
  • XGBoost vs. NN: XGBoost models generally require more training data but are faster to train than neural networks.

Limitations and Future Work

  • Model Size vs. Accuracy Trade-off: While the models are lightweight, there's still a trade-off between model size and accuracy. The paper focuses on finding the best models within a given memory budget.
  • Training Data Generation: Generating labeled training data (queries with actual selectivities) can be resource-intensive, although sampling and feedback mechanisms can mitigate this.
  • Handling Very High Dimensionality: While the models perform well up to 10 dimensions, handling datasets with significantly more numeric attributes (e.g., 100) poses further challenges, and the paper suggests partitioning attributes as a potential direction.
  • Future Work: The authors suggest exploring automatic attribute subset selection for model construction, handling more complex query types (like join queries), and further optimizing the training process.

Summary updated

BibTeX
@article{dutt2019selectivity,
  author = {Anshuman Dutt and Chi Wang and Azade Nazi and Srikanth Kandula and Vivek R. Narasayya and Surajit Chaudhuri},
  title = {{Selectivity Estimation for Range Predicates using Lightweight Models}},
  journal = {Proc. VLDB Endow.},
  year = {2019},
  url = {https://openreview.net/forum?id=xBiXlcimHAb},
}
Figure