Skip to main content
QUICK REVIEW

[论文解读] FactorJoin: A New Cardinality Estimation Framework for Join Queries

Zi‐Niu Wu, Parimarjan Negi|arXiv (Cornell University)|Dec 11, 2022
Data Management and Algorithms被引用 4
一句话总结

FactorJoin 是一种新颖的基数估计框架,通过结合单表学习分布与因子图推理,高效且准确地估计连接查询的选择性。与以往的端到端学习方法相比,它实现了 40 倍更低的延迟、100 倍更小的模型尺寸以及 100 倍更快的训练速度,同时在真实世界基准测试中达到或超越了最先进水平的准确性。

ABSTRACT

Cardinality estimation is one of the most fundamental and challenging problems in query optimization. Neither classical nor learning-based methods yield satisfactory performance when estimating the cardinality of the join queries. They either rely on simplified assumptions leading to ineffective cardinality estimates or build large models to understand the data distributions, leading to long planning times and a lack of generalizability across queries. In this paper, we propose a new framework FactorJoin for estimating join queries. FactorJoin combines the idea behind the classical join-histogram method to efficiently handle joins with the learning-based methods to accurately capture attribute correlation. Specifically, FactorJoin scans every table in a DB and builds single-table conditional distributions during an offline preparation phase. When a join query comes, FactorJoin translates it into a factor graph model over the learned distributions to effectively and efficiently estimate its cardinality. Unlike existing learning-based methods, FactorJoin does not need to de-normalize joins upfront or require executed query workloads to train the model. Since it only relies on single-table statistics, FactorJoin has small space overhead and is extremely easy to train and maintain. In our evaluation, FactorJoin can produce more effective estimates than the previous state-of-the-art learning-based methods, with 40x less estimation latency, 100x smaller model size, and 100x faster training speed at comparable or better accuracy. In addition, FactorJoin can estimate 10,000 sub-plan queries within one second to optimize the query plan, which is very close to the traditional cardinality estimators in commercial DBMS.

研究动机与目标

  • 解决传统基数估计器假设属性独立性及连接键分布均匀的局限性。
  • 克服现有基于学习的方法在去规范化或大规模连接数据上训练时效率低下与可扩展性差的问题。
  • 开发一种实用且可部署的框架,在最小化空间与时间开销的同时保持高精度,以支持查询优化。
  • 实现实时估计每秒数万个查询计划,以支持生产环境中动态查询优化。

提出的方法

  • 在离线准备阶段构建单表条件分布(例如,通过贝叶斯网络或深度生成模型),以捕捉属性相关性与连接键分布。
  • 将每个连接查询表示为基于学习到的单表分布的因子图,将基数估计转化为概率推理问题。
  • 使用基于边界的选择性分箱算法(GBSA)高效离散化连接键,降低计算复杂度。
  • 引入条件分布以建模过滤谓词如何影响连接键分布,从而在不进行去规范化的情况下提升估计精度。
  • 通过因子图消息传递将复杂的多连接查询分解为可处理的推理任务,避免完整物化连接关系。
  • 支持与任意单表基数估计器的插件式集成,使框架具备模块化与可扩展性。

实验结果

研究问题

  • RQ1结合单表学习统计与因子图推理的框架,是否能在连接基数估计中实现比经典方法或端到端学习方法更高的准确性?
  • RQ2避免去规范化与全表物化在多大程度上能减少模型大小与训练时间,同时保持估计质量?
  • RQ3条件分布(例如,P(join_key | filter))在不假设独立性的情况下,捕捉属性相关性的有效性如何?
  • RQ4该框架是否能够实现每秒估计 10,000 个子计划的规模,从而在实际中支持实时查询优化?
  • RQ5在多样化的现实世界工作负载中,该框架是否在准确性、延迟、模型大小与训练速度方面均优于最先进水平的基于学习与经典方法?

主要发现

  • 与先前最先进水平的学习方法相比,FactorJoin 将估计延迟降低了 40 倍,实现了对 10,000 个子计划的亚秒级估计。
  • FactorJoin 的模型尺寸比现有学习方法小 100 倍,使其在生产系统中可高效部署。
  • 由于无需去规范化与联合分布学习,FactorJoin 的训练速度相比以往学习方法提升了 100 倍。
  • 结合边界与条件优化后,FactorJoin 在端到端查询优化时间上相比先前最先进方法 JoinHist 提升了 45.9%。
  • FactorJoin 在查询执行时间上优于 Postgres 与所有现有最先进方法,展现出在多样化工作负载与超参数设置下的强大鲁棒性。
  • GBSA 分箱选择算法能有效生成高质量计划,且无论使用何种单表估计器,框架均保持稳定与高精度。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。