[Paper Review] Learned Cardinalities: Estimating Correlated Joins with Deep Learning
The paper introduces MSCN, a multi-set convolutional network that learns to predict join-crossing correlations for cardinality estimation, augmented with materialized-sample signals, and demonstrates robust improvements over baselines on IMDb data. It shows competitive median accuracy and strong performance in challenging 0-tuple scenarios.
We describe a new deep learning approach to cardinality estimation. MSCN is a multi-set convolutional network, tailored to representing relational query plans, that employs set semantics to capture query features and true cardinalities. MSCN builds on sampling-based estimation, addressing its weaknesses when no sampled tuples qualify a predicate, and in capturing join-crossing correlations. Our evaluation of MSCN using a real-world dataset shows that deep learning significantly enhances the quality of cardinality estimation, which is the core problem in query optimization.
Motivation & Objective
- Motivate improved cardinality estimation for complex, correlated joins to aid query optimization.
- Propose a neural model that leverages set-based query representations and sampling signals to capture join correlations.
- Reduce errors in 0-tuple situations where traditional sampling-based methods fail.
- Show robustness and generalization of MSCN across workloads including unseen join orders and JOB-like queries.
Proposed method
- Represent a query as three sets: tables, joins, predicates, with per-element one-hot encodings and optional sampling bitmaps.
- Introduce MSCN, which computes per-element MLP representations for each set, averages them, concatenates the results, and passes them through a final output MLP to predict cardinality.
- Normalize targets via log transform and map to [0,1]; train to minimize mean q-error using Adam optimizer.
- Enrich training data with materialized base-table sample information (counts and bitmaps) to help learn join-crossing correlations.
- Train on synthetic queries generated from schema and data, then evaluate on synthetic, scale, and JOB-light workloads to test generalization.
Experimental results
Research questions
- RQ1Can a set-based deep learning model accurately estimate cardinalities for queries with correlated joins?
- RQ2Does incorporating materialized sample information (counts/bitmaps) improve estimation, especially in 0-tuple cases?
- RQ3How well does the model generalize to unseen join orders and workloads different from training data?
- RQ4What is the trade-off between model size, training cost, and prediction latency?
Key findings
- MSCN achieves competitive median q-error versus IBJS and substantially better end-of-distribution accuracy on the synthetic workload (e.g., median q-error 1.18 for MSCN vs 1.09 for IBJS).
- In 0-tuple scenarios, MSCN dramatically outperforms purely sampling-based methods (e.g., MSCN median 2.94 vs PostgreSQL 4.78 and Random Sampling 9.13).
- Adding bitmaps and sample counts improves base-table and join estimates, with significant reductions in 95th/99th percentile q-errors across configurations.
- Generalization to more joins is possible: MSCN shows meaningful accuracy gains for 3- and 4-join queries not seen during training (e.g., 95th percentile q-error grows but remains far below some baselines; outliers exist).
- JOB-light results indicate MSCN can generalize to workloads from outside the training generator (median 3.82, 95th percentile 362; competitive with baselines).
- Model costs are modest (1.6–2.6 MiB) and inference runs in a few milliseconds, with training converging around 75 passes and ~39 minutes per run.
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.