NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Deep Unsupervised Cardinality Estimation

Zongheng Yang, Eric Liang, Amog Kamsetty, Chenggang Wu, Yan Duan, Xi Chen, Pieter Abbeel, Joseph M. Hellerstein, Sanjay Krishnan, Ion Stoica

Introduction

Cardinality estimation—predicting the number of rows returned by a query—is a fundamental challenge in database query optimization. Traditional methods often rely on simplistic independence assumptions between columns, leading to estimation errors that can exceed $10^4\times$ on real-world correlated data. While supervised learning approaches have emerged, they often struggle with workload shifts and require extensive query logs.

Naru (Neural Relation Understanding) addresses these issues by treating a database table as a high-dimensional probability distribution. As shown in Figure 1, Naru achieves near-perfect accuracy (comparable to an intractable "Full Joint" distribution) while maintaining a compact storage footprint, significantly outperforming traditional DBMS heuristics and sampling-based methods.

Naru achieves high accuracy with low storage overhead compared to traditional methods.

Methodology: Deep Autoregressive Modeling

The core of Naru is a deep unsupervised learning framework that factorizes the joint distribution of table columns using the probability product rule: $P(A_1, \dots, A_n) = \prod_{i=1}^n P(A_i | A_{<i})$.

By modeling the data as a chain of conditional probabilities, Naru captures complex inter-column correlations without manual feature engineering. The architecture, typically based on Masked Autoencoders (MADE) or Transformers, is trained using an unsupervised maximum likelihood loss as depicted in Figure 2.

The Naru architecture uses an autoregressive model to estimate selectivity via conditional probabilities.

Progressive Sampling

To handle range queries (e.g., price < 100), which require integrating over a region of the distribution, Naru introduces progressive sampling. Instead of uniform Monte Carlo sampling, which is inefficient in high-dimensional spaces, Naru uses its own conditional densities to "steer" samples into high-probability regions defined by the query filters. This drastically reduces the variance of the estimate and the number of samples required.

Handling Wildcards

Naru supports queries that do not filter on all columns by using a special MASK token during training. This allows the model to efficiently marginalize out unrequested columns during inference, a technique referred to as "wildcard-skipping."

Evaluation and Results

Naru was evaluated on real-world datasets including DMV (11.6M vehicle registrations) and Conviva-A (4.1M video analytics logs).

  • Accuracy: On the DMV dataset, Naru improved accuracy by 90\times over state-of-the-art supervised methods (MSCN) and 691\times over traditional multidimensional histograms (MHIST), maintaining low Q-errors even at the 99th percentile.
  • Efficiency: The models are highly compressed, typically requiring only ~1% of the original data size (e.g., 13MB for a 1GB table).
  • Latency: Inference is optimized for performance, producing estimates in 5–10ms on a GPU, meeting the requirements for real-time query optimization.

Conclusion and Future Work

Naru demonstrates that deep unsupervised models can effectively solve the cardinality estimation problem by learning the underlying data distribution directly. Unlike supervised models, Naru is robust to workload shifts. Future research directions include extending Naru to handle ad-hoc joins between multiple tables, optimizing model updates for streaming data environments, and reducing the reliance on GPU hardware for low-latency inference in CPU-bound database engines.

Summary updated

BibTeX
@article{yang2019deep,
  author = {Zongheng Yang and Eric Liang and Amog Kamsetty and Chenggang Wu and Yan Duan and Xi Chen and Pieter Abbeel and Joseph M. Hellerstein and Sanjay Krishnan and Ion Stoica},
  title = {{Deep Unsupervised Cardinality Estimation}},
  journal = {Proc. VLDB Endow.},
  year = {2019},
  doi = {10.14778/3368289.3368294},
}
Figure