arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2503.06902cs.DB
收藏

一种利用大型语言模型的查询优化方法

A Query Optimization Method Utilizing Large Language Models

Zhiming Yao, Haoyang Li, Jing Zhang, Cuiping Li, Hong Chen

AI总结:

本文提出LLMOpt框架,利用大型语言模型直接生成和全局选择查询计划,消除启发式搜索,并在多个基准上超越PostgreSQL、BAO等现有方法。

摘要:

查询优化是数据库系统中的一项关键任务,其重点是从大量可能的策略中确定执行查询的最高效方式。传统方法依赖启发式搜索和代价预测,但这些方法往往难以应对搜索空间的复杂性以及性能估计的不准确性,从而导致次优的计划选择。本文提出了LLMOpt,这是一个新颖的框架,通过两个创新组件利用大型语言模型(LLMs)来应对这些挑战:(1)用于计划候选生成的LLM(LLMOpt(G)),它利用LLMs的推理能力直接生成高质量的查询计划,从而消除了启发式搜索;(2)用于计划候选选择的LLM(LLMOpt(S)),这是一种列表式代价模型,能够全局比较候选计划以提高选择准确性。为了使LLMs适应查询优化,我们提出使用离线收集的优化数据对预训练模型进行微调。在JOB、JOB-EXT和Stack基准上的实验结果表明,LLMOpt(G)和LLMOpt(S)优于最先进的方法,包括PostgreSQL、BAO和HybridQO。值得注意的是,LLMOpt(S)实现了最佳的实用性能,在计划质量和推理效率之间取得了平衡。

英文摘要:

Query optimization is a critical task in database systems, focused on determining the most efficient way to execute a query from an enormous set of possible strategies. Traditional approaches rely on heuristic search methods and cost predictions, but these often struggle with the complexity of the search space and inaccuracies in performance estimation, leading to suboptimal plan choices. This paper presents LLMOpt, a novel framework that leverages Large Language Models (LLMs) to address these challenges through two innovative components: (1) LLM for Plan Candidate Generation (LLMOpt(G)), which eliminates heuristic search by utilizing the reasoning abilities of LLMs to directly generate high-quality query plans, and (2) LLM for Plan Candidate Selection (LLMOpt(S)), a list-wise cost model that compares candidates globally to enhance selection accuracy. To adapt LLMs for query optimization, we propose fine-tuning pre-trained models using optimization data collected offline. Experimental results on the JOB, JOB-EXT, and Stack benchmarks show that LLMOpt(G) and LLMOpt(S) outperform state-of-the-art methods, including PostgreSQL, BAO, and HybridQO. Notably, LLMOpt(S) achieves the best practical performance, striking a balance between plan quality and inference efficiency.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑