Introduction
Cardinality estimation—predicting the number of rows returned by a query—is a cornerstone of database query optimization. While Deep Learning (DL) models have recently achieved record-breaking accuracy in this domain, their "black-box" nature presents significant risks for production environments. Standard DL models provide point estimates without quantifying uncertainty, potentially leading to catastrophic query plans when encountering out-of-distribution data. Furthermore, these models often suffer from high training overhead and a tendency to overfit small datasets.
Methodology: The Neural Network Gaussian Process
To address these challenges, this research introduces a Neural Network Gaussian Process (NNGP) estimator. NNGP bridges the gap between the representational power of deep learning and the rigorous uncertainty quantification of Bayesian methods.
The core innovation lies in the mathematical convergence of infinitely wide neural networks to Gaussian Processes (GPs). By utilizing this "infinite width" limit, the NNGP offers several advantages:
- Exact Bayesian Inference: Instead of stochastic gradient descent, NNGP uses closed-form kernel functions, eliminating the need for backpropagation.
- Predictive Distributions: The model outputs a Gaussian distribution (mean and variance) rather than a single scalar. The variance provides a principled measure of uncertainty.
- Active Learning: This uncertainty signal enables "uncertainty sampling," where the system identifies and learns from queries the model is least confident about, significantly improving data efficiency.
Experimental Evaluation
The model was evaluated across diverse datasets, including single-relation tables (forest, higgs) and multi-relation join benchmarks (TPC-H, TPC-DS). The workloads included synthetic query logs with varying selection and join conditions to simulate real-world distribution shifts.
Key Insights and Results
A primary finding is that the NNGP's predicted uncertainty (coefficient of variation) is a highly reliable proxy for actual prediction error (q-error).
Key performance metrics include:
- Accuracy: NNGP consistently ranked in the top-3 against eight baselines, including GBDTs and specialized models like TLSTM.
- Efficiency: Training takes less than 3 seconds on a CPU, orders of magnitude faster than standard NNs or heavy data-driven models like NeuroCard.
- Robustness: When trained on limited data (1,000 queries), NNGP remained stable while standard NN errors exploded, demonstrating the strength of Bayesian priors against overfitting.
Conclusion and Future Directions
NNGP provides a fast, accurate, and uncertainty-aware solution for cardinality estimation. While the $O(N^3)$ complexity of Gaussian Processes remains a consideration for massive query logs, the model's high data efficiency mitigates this in practice. Future work may extend Bayesian Deep Learning to other database components, such as index recommendation and automated query tuning.
Summary updated