[论文解读] Making Databases Faster with LLM Evolutionary Sampling
论文提出 DBPlanBench,这是一个使用大语言模型来提出对数据库引擎物理查询计划的语义、局部编辑的工具,并使用进化采样来优化执行计划,在 OLAP 查询上达到最多 4.78x 加速,并展示了从小规模到大规模的可迁移性。
Traditional query optimization relies on cost-based optimizers that estimate execution cost (e.g., runtime, memory, and I/O) using predefined heuristics and statistical models. Improving these heuristics requires substantial engineering effort, and even when implemented, these heuristics often cannot take into account semantic correlations in queries and schemas that could enable better physical plans. Using our DBPlanBench harness for the DataFusion engine, we expose the physical plan through a compact serialized representation and let the LLM propose localized edits that can be applied and executed. We then apply an evolutionary search over these edits to refine candidates across iterations. Our key insight is that LLMs can leverage semantic knowledge to identify and apply non-obvious optimizations, such as join orderings that minimize intermediate cardinalities. We obtain up to 4.78$ imes$ speedups on some queries and we demonstrate a small-to-large workflow in which optimizations found on small databases transfer effectively to larger databases.
研究动机与目标
- 通过利用 LLM 的语义知识,推动超越传统基于成本的启发式优化的查询计划优化动机。
- 通过紧凑、符号高效的序列化,将数据库引擎的物理计划暴露给 LLM。
- 展示在语义基数估计引导下的局部计划编辑能够带来显著的加速。
- 证明在小型数据库上发现的优化能够有效迁移到更大数据库,同时保持性能提升。
提出的方法
- 通过专门的 JSON 序列化层将 DataFusion 物理计划暴露为紧凑表示。
- 为 LLM 提供计划和基于补丁的编辑接口,以生成局部的 JSON Patch 操作。
- 使用进化采样框架(PST-Evol 和 BoL-Evol)迭代应用补丁并在沙箱环境中评估端到端执行时间。
- 指示 LLM 进行语义基数估计,并提出 join-side 选择和 join-reordering 转换。
- 在 DataFusion 中执行转换后的计划,并在多个沙箱环境中衡量鲁棒性与正确性,以获得可靠的加速效果。

实验结果
研究问题
- RQ1一个利用语义知识的 LLM 是否能够发现超越传统基于规则的优化器的全局与局部优化?
- RQ2对序列化物理计划的局部 JSON Patch 编辑是否足以在不进行完整计划重写的情况下实现有意义的加速?
- RQ3在小规模上发现的优化是否可迁移至更大数据库,同时保持性能提升?
主要发现
- LLMs 可以实现显著的查询计划加速,在某些基于 TPC-DS 派生查询上实现最高 4.78x 的端到端改进。
- 平均来看,TPC-H 的中位加速约为 1.15x–1.2x,TPC-DS 的加速约为 1.1x,覆盖评估的工作负载。
- 语义、非显而易见的优化包括基于基数推理指导的 join 重排序和 join-side 交换,传统启发式方法可能忽视这些优化。
- 在小规模发现的优化能有效迁移到大规模数据库,并在确定性迁移过程下保持加速模式。
- 通常三步进化就足以达到接近峰值的加速,超过第3步的收益递减。
- 该方法在若干复杂多连接查询上优于基线 DataFusion 优化器。

阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。