arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2404.12872cs.DBcs.CL
收藏

LLM-R2:一种大语言模型增强的基于规则的查询重写系统,用于提升查询效率

LLM-R2: A Large Language Model Enhanced Rule-based Rewrite System for Boosting Query Efficiency

Nanyang Technological University(南洋理工大学);DAMO Academy(达摩院);Alibaba Group(阿里巴巴集团);Singapore University of Technology and Design(新加坡科技设计大学)

Zhaodonghui Li, Haitao Yuan, Huiming Wang, Gao Cong, Lidong Bing

AI总结:

针对查询重写中规则选择有限和依赖不准确成本估算器的问题,提出LLM-R2方法,利用大语言模型推荐重写规则,并通过课程对比学习增强推理,显著提升查询效率且鲁棒性高。

摘要:

查询重写旨在通过改变SQL查询的结构而不改变查询结果来生成更高效的查询,这一直是一个重要的研究问题。为了在重写过程中保持重写后查询与原始查询之间的等价性,传统的查询重写方法总是遵循一定的重写规则来重写查询。然而,仍存在一些问题。首先,现有的寻找最优重写规则选择或序列的方法仍然有限,且该过程往往耗费大量资源。发现新重写规则的方法通常需要对结构逻辑进行复杂的证明或进行大量的用户交互。其次,当前的查询重写方法通常高度依赖数据库管理系统(DBMS)的成本估算器,而这些估算器往往不准确。在本文中,我们通过提出一种名为LLM-R2的新型查询重写方法来解决这些问题,该方法采用大语言模型(LLM)为数据库重写系统提出可能的重写规则。为了进一步提升LLM在推荐重写规则方面的推理能力,我们通过课程学习训练了一个对比模型,以学习查询表示并为LLM选择有效的查询示例。实验结果表明,我们的方法能够显著提高查询执行效率,并优于基线方法。此外,我们的方法在不同数据集上具有较高的鲁棒性。

英文摘要:

Query rewrite, which aims to generate more efficient queries by altering a SQL query's structure without changing the query result, has been an important research problem. In order to maintain equivalence between the rewritten query and the original one during rewriting, traditional query rewrite methods always rewrite the queries following certain rewrite rules. However, some problems still remain. Firstly, existing methods of finding the optimal choice or sequence of rewrite rules are still limited and the process always costs a lot of resources. Methods involving discovering new rewrite rules typically require complicated proofs of structural logic or extensive user interactions. Secondly, current query rewrite methods usually rely highly on DBMS cost estimators which are often not accurate. In this paper, we address these problems by proposing a novel method of query rewrite named LLM-R2, adopting a large language model (LLM) to propose possible rewrite rules for a database rewrite system. To further improve the inference ability of LLM in recommending rewrite rules, we train a contrastive model by curriculum to learn query representations and select effective query demonstrations for the LLM. Experimental results have shown that our method can significantly improve the query execution efficiency and outperform the baseline methods. In addition, our method enjoys high robustness across different datasets.

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

↑