[Paper Review] NeuroCard: One Cardinality Estimator for All Tables
NeuroCard proposes a single, unified neural density estimator that models inter-table and inter-column correlations across an entire database schema without independence assumptions. By leveraging join sampling and deep autoregressive models, it achieves state-of-the-art cardinality estimation accuracy—up to 34× better than prior methods—while remaining compact (a few MB) and efficient to train (seconds to minutes).
Query optimizers rely on accurate cardinality estimates to produce good execution plans. Despite decades of research, existing cardinality estimators are inaccurate for complex queries, due to making lossy modeling assumptions and not capturing inter-table correlations. In this work, we show that it is possible to learn the correlations across all tables in a database without any independence assumptions. We present NeuroCard, a join cardinality estimator that builds a single neural density estimator over an entire database. Leveraging join sampling and modern deep autoregressive models, NeuroCard makes no inter-table or inter-column independence assumptions in its probabilistic modeling. NeuroCard achieves orders of magnitude higher accuracy than the best prior methods (a new state-of-the-art result of 8.5$ imes$ maximum error on JOB-light), scales to dozens of tables, while being compact in space (several MBs) and efficient to construct or update (seconds to minutes).
Motivation & Objective
- Address the critical challenge of inaccurate cardinality estimation in query optimization, especially for complex, multi-join queries.
- Overcome the limitations of existing data-driven estimators that rely on independence assumptions and fail to capture complex inter-table correlations.
- Develop a scalable, general-purpose cardinality estimator that works for any subset of tables in a schema without retraining.
- Reduce training cost and model size while maintaining high accuracy by sampling from full outer joins instead of computing full joins.
- Enable robust estimation under distributional shift by learning the full joint distribution of all tables without query-specific assumptions.
Proposed method
- Construct a single deep autoregressive (AR) model over the full outer join of all tables in the schema to capture all inter-table and inter-column correlations.
- Use a linear-time dynamic programming algorithm to precompute correct sampling weights for each key, enabling unbiased sampling from the full outer join distribution.
- Sample tuples from the full outer join using the computed weights to generate training data that preserves the true join distribution.
- Train a deep autoregressive model (e.g., based on flow-based or autoregressive normalizing flows) on the sampled data to learn the joint probability distribution.
- At inference, use the learned model to compute conditional probabilities and integrate over attributes to estimate selectivity and cardinality for any query on any subset of tables.
- Support complex predicates by sampling from the learned distribution and evaluating the predicate on sampled tuples.
Experimental results
Research questions
- RQ1Can a single neural density estimator model all inter-table and inter-column correlations in a database without independence assumptions?
- RQ2How can we efficiently train such a model without precomputing full outer joins, which are computationally prohibitive?
- RQ3Can we achieve high estimation accuracy across diverse query types and table combinations using a single, compact model?
- RQ4Does sampling from the full outer join distribution with correct weights yield a representative training distribution for cardinality estimation?
- RQ5How does the proposed method compare in accuracy and efficiency to existing query-driven and data-driven cardinality estimators?
Key findings
- NeuroCard achieves up to 34× higher accuracy than DeepDB and 8.5× lower maximum error than the best prior method on the JOB-light benchmark.
- The model achieves state-of-the-art performance on complex multi-join queries, significantly outperforming both query-driven and data-driven estimators.
- NeuroCard is compact, requiring only a few megabytes of storage, and can be trained or updated in seconds to minutes.
- The method scales to dozens of tables, demonstrating practicality for real-world database schemas.
- By learning the full joint distribution without independence assumptions, NeuroCard captures complex correlations that traditional estimators miss.
- The use of weighted join sampling ensures that the training data is representative of the true join distribution, enabling accurate generalization to any query on any subset of tables.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.