Large language model (LLM) has marked a pivotal moment in the field of machine learning and deep learning. Recently its capability for query planning has been investigated, including both single-modal and multi-modal queries. However, there is no work on the query optimization capability of LLM. As a critical (or could even be the most important) step that significantly impacts the execution performance of the query plan, such analysis and attempts should not be missed. From another aspect, existing query optimizers are usually rule-based or rule-based + cost-based, i.e., they are dependent on manually created rules to complete the query plan rewrite/transformation. Given the fact that modern optimizers include hundreds to thousands of rules, designing a multi-modal query optimizer following a similar way is significantly time-consuming since we will have to enumerate as many multi-modal optimization rules as possible, which has not been well addressed today. In this paper, we investigate the query optimization ability of LLM and use LLM to design LaPuda, a novel LLM and Policy based multi-modal query optimizer. Instead of enumerating specific and detailed rules, LaPuda only needs a few abstract policies to guide LLM in the optimization, by which much time and human effort are saved. Furthermore, to prevent LLM from making mistakes or negative optimization, we borrow the idea of gradient descent and propose a guided cost descent (GCD) algorithm to perform the optimization, such that the optimization can be kept in the correct direction. In our evaluation, our methods consistently outperform the baselines in most cases. For example, the optimized plans generated by our methods result in 1~3x higher execution speed than those by the baselines.
翻译:大语言模型(LLM)标志着机器学习和深度学习领域的关键转折点。近期,其查询规划能力已得到研究,涵盖单模态和多模态查询。然而,目前尚无关于LLM查询优化能力的研究。作为显著影响查询计划执行性能的关键(甚至可能是最重要)步骤,此类分析与尝试不容忽视。另一方面,现有查询优化器通常基于规则或“规则+代价”模式,即依赖人工编写规则完成查询计划重写/转换。鉴于现代优化器包含数百至数千条规则,以类似方式设计多模态查询优化器需枚举尽可能多的多模态优化规则,耗时且至今未获妥善解决。本文研究LLM的查询优化能力,并利用LLM设计LaPuda——一种新颖的基于大语言模型和策略的多模态查询优化器。LaPuda无需枚举具体详细的规则,仅需少量抽象策略引导LLM进行优化,从而节省大量时间与人力。此外,为防止LLM出错或产生负面优化,我们借鉴梯度下降思想,提出引导式代价下降(GCD)算法执行优化,确保优化方向正确。实验评估中,我们的方法在多数情况下持续优于基线方案。例如,经方法优化的查询计划执行速度比基线方案快1~3倍。