Flow-Loss: Learning Cardinality Estimates That Matter
Parimarjan Negi, Ryan Marcus, Andreas Kipf, Hongzi Mao, Nesime Tatbul, Tim Kraska, Mohammad Alizadeh
Abstract
Previous approaches to learned cardinality estimation have focused on improving average estimation error, but not all estimates matter equally. Since learned models inevitably make mistakes, the goal should be to improve the estimates that make the biggest difference to an optimizer. We introduce a new loss function, Flow-Loss, that explicitly optimizes for better query plans by approximating the optimizer's cost model and dynamic programming search algorithm with analytical functions. At the heart of Flow-Loss is a reduction of query optimization to a flow routing problem on a certain plan graph in which paths correspond to different query plans. To evaluate our approach, we introduce the Cardinality Estimation Benchmark (CEB) which contains the ground truth cardinalities for sub-plans of over 16K queries from 21 templates with up to 15 joins. We show that across different architectures and databases, a model trained with Flow-Loss improves the cost of plans (using the PostgreSQL cost model) and query runtimes despite having worse estimation accuracy than a model trained with Q-Error. When the test set queries closely match the training queries, both models improve performance significantly over PostgreSQL and are close to the optimal performance (using true cardinalities). However, the Q-Error trained model degrades significantly when evaluated on queries that are slightly different (e.g., similar but not identical query templates), while the Flow-Loss trained model generalizes better to such situations. For example, the Flow-Loss model achieves up to 1.5× better runtimes on unseen templates compared to the Q-Error model, despite leveraging the same model architecture and training data.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
52 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- FactorJoin: A New Cardinality Estimation Framework for Join Queries cites Deep Learning Models for Selectivity Estimation of Multi-Attribute Queries
- FactorJoin: A New Cardinality Estimation Framework for Join Queries cites Fauce: Fast and Accurate Deep Ensembles with Uncertainty for Cardinality Estimation
- FactorJoin: A New Cardinality Estimation Framework for Join Queries cites An End-to-End Learning-based Cost Estimator
- FactorJoin: A New Cardinality Estimation Framework for Join Queries cites NeuroCard: One Cardinality Estimator for All Tables
- Robust Query Driven Cardinality Estimation under Changing Workloads cites FactorJoin: A New Cardinality Estimation Framework for Join Queries
- Robust Query Driven Cardinality Estimation under Changing Workloads cites Deep Learning Models for Selectivity Estimation of Multi-Attribute Queries
- Robust Query Driven Cardinality Estimation under Changing Workloads cites Are We Ready For Learned Cardinality Estimation?
- Robust Query Driven Cardinality Estimation under Changing Workloads cites Fauce: Fast and Accurate Deep Ensembles with Uncertainty for Cardinality Estimation
- Robust Query Driven Cardinality Estimation under Changing Workloads cites Learned Cardinality Estimation: An In-depth Study
- Robust Query Driven Cardinality Estimation under Changing Workloads cites Deep Unsupervised Cardinality Estimation
- Robust Query Driven Cardinality Estimation under Changing Workloads cites Cardinality Estimation in DBMS: A Comprehensive Benchmark Evaluation
- Robust Query Driven Cardinality Estimation under Changing Workloads cites NeuroCard: One Cardinality Estimator for All Tables
- Are We Ready For Learned Cardinality Estimation? cites Deep Learning Models for Selectivity Estimation of Multi-Attribute Queries
- Are We Ready For Learned Cardinality Estimation? cites Deep Unsupervised Cardinality Estimation
- Are We Ready For Learned Cardinality Estimation? cites An End-to-End Learning-based Cost Estimator
- Are We Ready For Learned Cardinality Estimation? cites NeuroCard: One Cardinality Estimator for All Tables
- Fauce: Fast and Accurate Deep Ensembles with Uncertainty for Cardinality Estimation cites Deep Learning Models for Selectivity Estimation of Multi-Attribute Queries
- Fauce: Fast and Accurate Deep Ensembles with Uncertainty for Cardinality Estimation cites Are We Ready For Learned Cardinality Estimation?
- Fauce: Fast and Accurate Deep Ensembles with Uncertainty for Cardinality Estimation cites Deep Unsupervised Cardinality Estimation
- Fauce: Fast and Accurate Deep Ensembles with Uncertainty for Cardinality Estimation cites NeuroCard: One Cardinality Estimator for All Tables
- Learned Cardinality Estimation: An In-depth Study cites Deep Learning Models for Selectivity Estimation of Multi-Attribute Queries
- Learned Cardinality Estimation: An In-depth Study cites Are We Ready For Learned Cardinality Estimation?
- Learned Cardinality Estimation: An In-depth Study cites Fauce: Fast and Accurate Deep Ensembles with Uncertainty for Cardinality Estimation
- Learned Cardinality Estimation: An In-depth Study cites Deep Unsupervised Cardinality Estimation
- Learned Cardinality Estimation: An In-depth Study cites An End-to-End Learning-based Cost Estimator
- Learned Cardinality Estimation: An In-depth Study cites NeuroCard: One Cardinality Estimator for All Tables
- Cardinality Estimation in DBMS: A Comprehensive Benchmark Evaluation cites Deep Learning Models for Selectivity Estimation of Multi-Attribute Queries
- Cardinality Estimation in DBMS: A Comprehensive Benchmark Evaluation cites Are We Ready For Learned Cardinality Estimation?
- Cardinality Estimation in DBMS: A Comprehensive Benchmark Evaluation cites An End-to-End Learning-based Cost Estimator
- Cardinality Estimation in DBMS: A Comprehensive Benchmark Evaluation cites NeuroCard: One Cardinality Estimator for All Tables
- NeuroCard: One Cardinality Estimator for All Tables cites Deep Unsupervised Cardinality Estimation
- NeuroCard: One Cardinality Estimator for All Tables cites An End-to-End Learning-based Cost Estimator
Cited by top-tier papers52
- Cardinality Estimation in DBMS: A Comprehensive Benchmark EvaluationYuxing Han, Ziniu Wu, Peizhi Wu, Rong Zhu et al.VLDB 2022 · 169 citations
- Robust Query Driven Cardinality Estimation under Changing WorkloadsParimarjan Negi, Ziniu Wu, Andreas Kipf, Nesime Tatbul et al.VLDB 2023 · 88 citations
- Fauce: Fast and Accurate Deep Ensembles with Uncertainty for Cardinality EstimationJie Liu, Wenqian Dong, Dong Li, Qingqing ZhouVLDB 2021 · 71 citations
- FactorJoin: A New Cardinality Estimation Framework for Join QueriesZiniu Wu, Parimarjan Negi, Mohammad Alizadeh, Tim Kraska et al.SIGMOD 2023 · 54 citations
- Learned Cardinality Estimation: An In-depth StudyKyoungmin Kim, Jisung Jung, In Seo, Wook-Shin Han et al.SIGMOD 2022 · 51 citations
Builds on7
- An End-to-End Learning-based Cost EstimatorJi Sun, Guoliang LiVLDB 2020 · 251 citations
- Deep Unsupervised Cardinality EstimationZongheng Yang, Eric Liang, Amog Kamsetty, Chenggang Wu et al.VLDB 2020 · 206 citations
- Are We Ready For Learned Cardinality Estimation?Xiaoying Wang, Changbo Qu, Weiyuan Wu, Jiannan Wang et al.VLDB 2021 · 156 citations
- NeuroCard: One Cardinality Estimator for All TablesZongheng Yang, Amog Kamsetty, Sifei Luan, Eric Liang et al.VLDB 2021 · 138 citations
- Deep Learning Models for Selectivity Estimation of Multi-Attribute QueriesShohedul Hasan, Saravanan Thirumuruganathan, Jees Augustine, Nick Koudas et al.SIGMOD 2020 · 101 citations
Related papers
- Sub-optimal Join Order Identification with L1-errorYesdaulet Izenov, Asoke Datta, Brian Tsan, Florin RusuSIGMOD 2024 · 1 citation
- Speeding Up End-to-end Query Execution via Learning-based Progressive Cardinality EstimationFang Wang, Xiao Yan, Man Lung Yiu, Shuai Li et al.SIGMOD 2023 · 24 citations
- Sample-Efficient Cardinality Estimation Using Geometric Deep LearningSilvan Reiner, Michael GrossniklausVLDB 2024 · 20 citations
- LpBound: Pessimistic Cardinality Estimation Using ℓp-Norms of Degree SequencesHaozhe Zhang, Christoph Mayer, Mahmoud Abo Khamis, Dan Olteanu et al.SIGMOD 2025 · 7 citations
- Warper: Efficiently Adapting Learned Cardinality Estimators to Data and Workload DriftsBeibin Li, Yao Lu, Srikanth KandulaSIGMOD 2022 · 29 citations
