[论文解读] Cardinality Estimation in DBMS: A Comprehensive Benchmark Evaluation
本文提出了一套全面的数据库管理系统(DBMS)基数估计(CardEst)基准测试,使用真实世界数据集(STATS)和多样化工作负载(STATS-CEB)在PostgreSQL中评估了12种最先进的方法。研究提出了一项新指标P-Error,其与端到端查询性能的相关性优于传统Q-Error指标,揭示出模型准确率与推理效率共同决定优化器改进效果,并表明在实践中,数据驱动的机器学习方法优于查询驱动的方法。
Cardinality estimation (CardEst) plays a significant role in generating high-quality query plans for a query optimizer in DBMS. In the last decade, an increasing number of advanced CardEst methods (especially ML-based) have been proposed with outstanding estimation accuracy and inference latency. However, there exists no study that systematically evaluates the quality of these methods and answer the fundamental problem: to what extent can these methods improve the performance of query optimizer in real-world settings, which is the ultimate goal of a CardEst method. In this paper, we comprehensively and systematically compare the effectiveness of CardEst methods in a real DBMS. We establish a new benchmark for CardEst, which contains a new complex real-world dataset STATS and a diverse query workload STATS-CEB. We integrate multiple most representative CardEst methods into an open-source database system PostgreSQL, and comprehensively evaluate their true effectiveness in improving query plan quality, and other important aspects affecting their applicability, ranging from inference latency, model size, and training time, to update efficiency and accuracy. We obtain a number of key findings for the CardEst methods, under different data and query settings. Furthermore, we find that the widely used estimation accuracy metric(Q-Error) cannot distinguish the importance of different sub-plan queries during query optimization and thus cannot truly reflect the query plan quality generated by CardEst methods. Therefore, we propose a new metric P-Error to evaluate the performance of CardEst methods, which overcomes the limitation of Q-Error and is able to reflect the overall end-to-end performance of CardEst methods. We have made all of the benchmark data and evaluation code publicly available at https://github.com/Nathaniel-Han/End-to-End-CardEst-Benchmark.
研究动机与目标
- 为解决在真实DBMS工作负载中对CardEst方法缺乏系统性、端到端评估的问题。
- 识别现有评估实践中的不足,特别是对Q-Error等算法级指标的过度依赖。
- 建立一个反映复杂真实DBMS场景的新基准,包含真实数据和查询工作负载。
- 提出并验证一种新指标P-Error,更好地反映CardEst对查询执行时间的实际影响。
- 为研究人员提供可操作的见解,以设计更高效、实用且可扩展的CardEst方法。
提出的方法
- 从实际业务数据中构建了一个具有高偏度、相关性及复杂模式的真实世界基准数据集(STATS)。
- 设计了一个多样化的查询工作负载(STATS-CEB),涵盖多表连接、多种连接类型及选择性谓词。
- 将12种具有代表性的CardEst方法——包括传统方法、查询驱动型和数据驱动型机器学习模型——集成到开源PostgreSQL中。
- 提出P-Error作为新评估指标,基于其对计划成本的影响聚合子计划误差,以反映端到端优化器性能。
- 开展端到端评估,测量查询执行时间、推理延迟、模型大小、训练时间及更新效率。
- 通过相关性分析比较P-Error与Q-Error在实际查询执行时间上的表现,验证P-Error的优越性。
实验结果
研究问题
- RQ1在真实世界的DBMS环境中,先进CardEst方法在多大程度上提升了查询优化器性能?
- RQ2传统算法级指标(如Q-Error)在多大程度上能反映实际的端到端查询性能?
- RQ3哪些CardEst方法在估计准确率、推理速度和更新效率之间提供了最佳权衡?
- RQ4不同子计划的估计误差如何影响最终查询计划的质量和执行时间?
- RQ5像P-Error这样的新指标是否能比Q-Error更好地预测真实世界查询性能?
主要发现
- P-Error指标与实际查询执行时间具有强相关性(第50至90百分位数相关系数为0.810–0.838),而Q-Error的相关性接近零(0.036–0.037),证明P-Error是真实性能的更优预测指标。
- 数据驱动的机器学习CardEst方法(如FLAT、DeepDB和BayesCard)通过在模型表达能力与推理效率之间取得平衡,显著提升了端到端查询性能。
- 查询驱动的机器学习方法相比PostgreSQL基线几乎未带来改进,原因在于其可扩展性差且推理成本高。
- 传统方法以及部分数据驱动模型(如PessEst、BayesCard)支持快速更新,适用于动态、实时的DBMS工作负载。
- 在包含超过4–5张表的多表连接查询中,模型性能显著下降,尤其对大规模数据驱动模型影响更明显。
- 仅优化Q-Error并不能保证获得更优的查询计划,因为高基数子计划中的误差对计划质量具有不成比例的影响。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。