TiCard通过修正现有估算器,显著提升数据库查询基数估计精度。
TiCard: Deployable EXPLAIN-only Residual Learning for Cardinality Estimation
- 用仅依赖EXPLAIN的特征学习乘法残差校正,无需修改优化器
- 在低采样场景下,尾部误差降低至原系统1/20以下
- 适合希望快速部署且不改动核心引擎的数据库系统
基数估计是基于代价查询优化的关键瓶颈,但可部署的改进仍面临挑战:传统估算器忽略数据相关性,而学习型方法常需针对工作负载定制训练流程并侵入优化器。本文提出TiCard,一种低侵入性的校正框架,通过补充而非替换数据库原生估算器来实现改进。TiCard利用仅需EXPLAIN的特征学习乘法残差校正,并仅在离线阶段使用EXPLAIN ANALYZE生成标签。我们实现了两种实用方案:(i) 毫秒级推理的梯度提升回归器,(ii) 基于上下文学习的表格式基础模型TabPFN,通过更新小参考集即可适应,无需梯度重训练。在TiDB上,结合TPCH与连接顺序基准测试,在仅263次执行(其中157次用于学习)的低追踪设置下,操作符级尾部准确率显著提升:P90 Q-error从原生系统的312.85降至13.69(TiCard-GBR),P99从37,974.37降至3,416.50(TiCard-TabPFN),同时连接策略保持接近完美的中位数表现。我们定位TiCard为面向可部署性的AI4DB核心组件,强调明确范围、保守集成策略及从离线校正到内嵌优化器的演进路径。
原文摘要 · Abstract (English)
Cardinality estimation is a key bottleneck for cost-based query optimization, yet deployable improvements remain difficult: classical estimators miss correlations, while learned estimators often require workload-specific training pipelines and invasive integration into the optimizer. This paper presents TiCard, a low intrusion, correction-based framework that augments (rather than replaces) a database's native estimator. TiCard learns multiplicative residual corrections using EXPLAIN-only features, and uses EXPLAIN ANALYZE only for offline labels. We study two practical instantiations: (i) a Gradient Boosting Regressor for sub-millisecond inference, and (ii) TabPFN, an in-context tabular foundation model that adapts by refreshing a small reference set without gradient retraining. On TiDB with TPCH and the Join Order Benchmark, in a low-trace setting (263 executions total; 157 used for learning), TiCard improves operator-level tail accuracy substantially: P90 Q-error drops from 312.85 (native) to 13.69 (TiCard-GBR), and P99 drops from 37,974.37 to 3,416.50 (TiCard-TabPFN), while a join-only policy preserves near-perfect median behavior. We position TiCard as an AI4DB building block focused on deployability: explicit scope, conservative integration policies, and an integration roadmap from offline correction to in-optimizer use.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。