Flow-Loss: Learning Cardinality Estimates That Matter
Not on the map. Why?
Abstract (arXiv)
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, 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.5x better runtimes on unseen templates compared to the Q-Error model, despite leveraging the same model architecture and training data.
Key facts. Cited by 22 papers in the map (data through 14 Oct 2026). First posted on arXiv 13 Jan 2021.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2021: 2; 2022: 2; 2023: 1; 2024: 8; 2025: 7; 2026: 2.
22 papers.
Sort:
By area:
- 2021Cardinality Estimation in DBMS: A Comprehensive Benchmark Evaluationcited by 30
- 2022FactorJoin: A New Cardinality Estimation Framework for Join Queriescited by 13
- 2021A Unified Transferable Model for ML-Enhanced DBMScited by 10
- 2024E2ETune: End-to-End Knob Tuning via Fine-tuned Generative Language Modelcited by 9
- 2024CardBench: A Benchmark for Learned Cardinality Estimation in Relational Databasescited by 4
- 2024The Unreasonable Effectiveness of LLMs for Query Optimizationcited by 4
- 2024Theoretical Analysis of Learned Database Operations under Distribution Shift through Distribution Learnabilitycited by 4
- 2023Kepler: Robust Learning for Faster Parametric Query Optimizationcited by 3
- 2024A Practical Theory of Generalization in Selectivity Learningcited by 3
- 2024HERO: Hint-Based Efficient and Reliable Query Optimizercited by 3
- 2025In-Context Adaptation to Concept Drift for Learned Database Operationscited by 3
- 2022Learned-Database Systems Securitycited by 2
10 more
- 2024Towards Establishing Guaranteed Error for Learned Database Operationscited by 2
- 2024Robust Plan Evaluation based on Approximate Probabilistic Machine Learningcited by 1
- 2025Large Scale Multi-Task Bayesian Optimization with Large Language Modelscited by 1
- 2025Data-Agnostic Cardinality Learning from Imperfect Workloadscited by 1
- 2026When Does q-error Predict Plan Regret? Three Regimes of Cardinality-Estimation Errorcited by 1
- 2025Reqo: A Comprehensive Learning-Based Cost Model for Robust and Explainable Query Optimizationcited by 0
- 2025Low Rank Learning for Offline Query Optimizationcited by 0
- 2025ZeroCard: Cardinality Estimation with Zero Dependence on Target Databases -- No Data, No Query, No Retrainingcited by 0
- 2025CoLSE: A Lightweight and Robust Hybrid Learned Model for Single-Table Cardinality Estimation using Joint CDFcited by 0
- 2026Fully Inductive Cardinality Estimationcited by 0
- 2026Fully Inductive Cardinality Estimation30 Jul 2026
- 2026When Does q-error Predict Plan Regret? Three Regimes of Cardinality-Estimation Error14 Jun 2026
- 2025CoLSE: A Lightweight and Robust Hybrid Learned Model for Single-Table Cardinality Estimation using Joint CDF14 Dec 2025
- 2025ZeroCard: Cardinality Estimation with Zero Dependence on Target Databases -- No Data, No Query, No Retraining9 Oct 2025
- 2025Data-Agnostic Cardinality Learning from Imperfect Workloads19 Jun 2025
- 2025In-Context Adaptation to Concept Drift for Learned Database Operations7 May 2025
- 2025Low Rank Learning for Offline Query Optimization8 Apr 2025
- 2025Large Scale Multi-Task Bayesian Optimization with Large Language Models11 Mar 2025
- 2025Reqo: A Comprehensive Learning-Based Cost Model for Robust and Explainable Query Optimization29 Jan 2025
- 2024HERO: Hint-Based Efficient and Reliable Query Optimizer3 Dec 2024
- 2024Towards Establishing Guaranteed Error for Learned Database Operations9 Nov 2024
- 2024Theoretical Analysis of Learned Database Operations under Distribution Shift through Distribution Learnability9 Nov 2024
10 more
- 2024The Unreasonable Effectiveness of LLMs for Query Optimization5 Nov 2024
- 2024A Practical Theory of Generalization in Selectivity Learning11 Sep 2024
- 2024CardBench: A Benchmark for Learned Cardinality Estimation in Relational Databases28 Aug 2024
- 2024E2ETune: End-to-End Knob Tuning via Fine-tuned Generative Language Model17 Apr 2024
- 2024Robust Plan Evaluation based on Approximate Probabilistic Machine Learning26 Jan 2024
- 2023Kepler: Robust Learning for Faster Parametric Query Optimization11 Jun 2023
- 2022Learned-Database Systems Security20 Dec 2022
- 2022FactorJoin: A New Cardinality Estimation Framework for Join Queries11 Dec 2022
- 2021Cardinality Estimation in DBMS: A Comprehensive Benchmark Evaluation13 Sep 2021
- 2021A Unified Transferable Model for ML-Enhanced DBMS6 May 2021
- 2021Cardinality Estimation in DBMS: A Comprehensive Benchmark Evaluationcited by 30
- 2022FactorJoin: A New Cardinality Estimation Framework for Join Queriescited by 13
- 2021A Unified Transferable Model for ML-Enhanced DBMScited by 10
- 2024E2ETune: End-to-End Knob Tuning via Fine-tuned Generative Language Modelcited by 9
- 2024CardBench: A Benchmark for Learned Cardinality Estimation in Relational Databasescited by 4
- 2024Theoretical Analysis of Learned Database Operations under Distribution Shift through Distribution Learnabilitycited by 4
- 2023Kepler: Robust Learning for Faster Parametric Query Optimizationcited by 3
- 2024A Practical Theory of Generalization in Selectivity Learningcited by 3
- 2024HERO: Hint-Based Efficient and Reliable Query Optimizercited by 3
- 2025In-Context Adaptation to Concept Drift for Learned Database Operationscited by 3
- 2022Learned-Database Systems Securitycited by 2
- 2024Towards Establishing Guaranteed Error for Learned Database Operationscited by 2
12 most cited of 21 All 21 (JSON)
- 2026Fully Inductive Cardinality Estimation30 Jul 2026
- 2026When Does q-error Predict Plan Regret? Three Regimes of Cardinality-Estimation Error14 Jun 2026
- 2025CoLSE: A Lightweight and Robust Hybrid Learned Model for Single-Table Cardinality Estimation using Joint CDF14 Dec 2025
- 2025ZeroCard: Cardinality Estimation with Zero Dependence on Target Databases -- No Data, No Query, No Retraining9 Oct 2025
- 2025Data-Agnostic Cardinality Learning from Imperfect Workloads19 Jun 2025
- 2025In-Context Adaptation to Concept Drift for Learned Database Operations7 May 2025
- 2025Low Rank Learning for Offline Query Optimization8 Apr 2025
- 2025Large Scale Multi-Task Bayesian Optimization with Large Language Models11 Mar 2025
- 2025Reqo: A Comprehensive Learning-Based Cost Model for Robust and Explainable Query Optimization29 Jan 2025
- 2024HERO: Hint-Based Efficient and Reliable Query Optimizer3 Dec 2024
- 2024Towards Establishing Guaranteed Error for Learned Database Operations9 Nov 2024
- 2024Theoretical Analysis of Learned Database Operations under Distribution Shift through Distribution Learnability9 Nov 2024
12 newest of 21 All 21 (JSON)