LLM-R <sup>2</sup> : A Large Language Model Enhanced Rule-Based Rewrite System for Boosting Query Efficiency

Query rewrite, which aims to improve query efficiency by altering an SQL query's structure without changing its 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. First, 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. Second, 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 query rewrite method named LLM-R 2 , which leverages a large language model (LLM) to recommend rewrite rules for a database rewrite system. To further enhance the inference ability of the LLM in recommending rewrite rules, we train a contrastive model using a curriculum-based approach to learn query representations and select effective query demonstrations for the LLM. Experimental results show that our method significantly improves the query execution efficiency and outperforms the baseline methods. In addition, our method exhibits high robustness across different datasets.

Authors

Institutions

Publication Details

Journal
Proceedings of the VLDB Endowment
Published
2024-09-01
DOI
https://doi.org/10.14778/3696435.3696440
Citations
8
Primary Topic
Advanced Database Systems and Queries
Type
article
Field-Weighted Citation Impact
2.79
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

LLM-R 2 : A Large Language Model Enhanced Rule-Based Rewrite System for Boosting Query Efficiency

Gao Cong, Haitao Yuan, Lidong Bing, Hui‐Ming Wang et al.
8 citations
Proceedings of the VLDB Endowment
Advanced Database Systems and Queries
2.79
article

LLM-R 2 : A Large Language Model Enhanced Rule-Based Rewrite System for Boosting Query Efficiency

Gao Cong, Haitao Yuan, Lidong Bing, Hui‐Ming Wang, Zhaodonghui Li
article en
8 citations

Abstract

Query rewrite, which aims to improve query efficiency by altering an SQL query's structure without changing its 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. First, 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. Second, 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 query rewrite method named LLM-R 2 , which leverages a large language model (LLM) to recommend rewrite rules for a database rewrite system. To further enhance the inference ability of the LLM in recommending rewrite rules, we train a contrastive model using a curriculum-based approach to learn query representations and select effective query demonstrations for the LLM. Experimental results show that our method significantly improves the query execution efficiency and outperforms the baseline methods. In addition, our method exhibits high robustness across different datasets.

Proceedings of the VLDB EndowmentVol. 18(1)
Singapore University of Technology and Design (SG), Nanyang Technological University (SG)
Openalex Percentile: Top 8%
Advanced Database Systems and Queries
2.79
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.