{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,11,3]],"date-time":"2026-11-03T13:23:51Z","timestamp":1793712231514,"version":"4.6.1"},"reference-count":46,"publisher":"Association for Computing Machinery (ACM)","issue":"1","content-domain":{"domain":["dl.acm.org"],"crossmark-restriction":true},"short-container-title":["Proc. VLDB Endow."],"published-print":{"date-parts":[[2024,9]]},"abstract":"<jats:p>\n            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\n            <jats:sup>2<\/jats:sup>\n            , 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.\n          <\/jats:p>","DOI":"10.14778\/3696435.3696440","type":"journal-article","created":{"date-parts":[[2025,2,11]],"date-time":"2025-02-11T20:41:46Z","timestamp":1739306506000},"page":"53-65","update-policy":"https:\/\/doi.org\/10.1145\/crossmark-policy","source":"Crossref","is-referenced-by-count":29,"title":["LLM-R\n            <sup>2<\/sup>\n            : A Large Language Model Enhanced Rule-Based Rewrite System for Boosting Query Efficiency"],"prefix":"10.14778","volume":"18","author":[{"given":"Zhaodonghui","family":"Li","sequence":"first","affiliation":[{"name":"Nanyang Technological University, DAMO Academy Alibaba Group, Singapore"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"given":"Haitao","family":"Yuan","sequence":"additional","affiliation":[{"name":"Nanyang Technological University, Singapore"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"given":"Huiming","family":"Wang","sequence":"additional","affiliation":[{"name":"Singapore University of Technology and Design, Singapore"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"given":"Gao","family":"Cong","sequence":"additional","affiliation":[{"name":"Nanyang Technological University, Singapore"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"given":"Lidong","family":"Bing","sequence":"additional","affiliation":[{"name":"DAMO Academy, Alibaba Group, Singapore"}],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"320","published-online":{"date-parts":[[2025,2,11]]},"reference":[{"key":"e_1_2_1_1_1","unstructured":"[n.d.]. Apache Calcite Rewrite Rules. https:\/\/calcite.apache.org\/javadocAggregate\/org\/apache\/calcite\/rel\/rules\/package-summary.html."},{"key":"e_1_2_1_2_1","unstructured":"[n.d.]. Introduction of OpenAI Text Generation APIs. https:\/\/platform.openai.com\/docs\/guides\/text-generation."},{"key":"e_1_2_1_3_1","unstructured":"[n.d.]. LLM As Database Administrator. https:\/\/github.com\/TsinghuaDatabaseGroup\/DB-GPT."},{"key":"e_1_2_1_4_1","unstructured":"[n.d.]. PostgreSQL. https:\/\/www.postgresql.org."},{"key":"e_1_2_1_5_1","unstructured":"[n.d.]. TPC-H Toolkit. https:\/\/www.tpc.org\/tpc_documents_current_versions\/current_specifications5.asp."},{"key":"e_1_2_1_6_1","volume-title":"MAGIC: Generating Self-Correction Guideline for In-Context Text-to-SQL. CoRR abs\/2406.12692","author":"Askari Arian","year":"2024","unstructured":"Arian Askari, Christian Poelitz, and Xinye Tang. 2024. MAGIC: Generating Self-Correction Guideline for In-Context Text-to-SQL. CoRR abs\/2406.12692 (2024)."},{"key":"e_1_2_1_7_1","doi-asserted-by":"publisher","DOI":"10.14778\/3611479.3611497"},{"key":"e_1_2_1_8_1","doi-asserted-by":"publisher","DOI":"10.1145\/3183713.3190662"},{"key":"e_1_2_1_9_1","doi-asserted-by":"publisher","DOI":"10.1145\/1553374.1553380"},{"key":"e_1_2_1_10_1","unstructured":"Tom B. Brown Benjamin Mann Nick Ryder Melanie Subbiah Jared Kaplan Prafulla Dhariwal Arvind Neelakantan Pranav Shyam Girish Sastry Amanda Askell Sandhini Agarwal Ariel Herbert-Voss Gretchen Krueger Tom Henighan Rewon Child Aditya Ramesh Daniel M. Ziegler Jeffrey Wu Clemens Winter Christopher Hesse Mark Chen Eric Sigler Mateusz Litwin Scott Gray Benjamin Chess Jack Clark Christopher Berner Sam McCandlish Alec Radford Ilya Sutskever and Dario Amodei. 2020. In NeurIPS."},{"key":"e_1_2_1_11_1","volume-title":"Curriculum Labeling: Revisiting Pseudo-Labeling for Semi-Supervised Learning. In AAAI. 6912--6920.","author":"Cascante-Bonilla Paola","year":"2021","unstructured":"Paola Cascante-Bonilla, Fuwen Tan, Yanjun Qi, and Vicente Ordonez. 2021. Curriculum Labeling: Revisiting Pseudo-Labeling for Semi-Supervised Learning. In AAAI. 6912--6920."},{"key":"e_1_2_1_12_1","unstructured":"Daniel M. Cer Mona T. Diab Eneko Agirre I\u00f1igo Lopez-Gazpio and Lucia Specia. [n.d.]. SemEval-2017 Task 1: Semantic Textual Similarity Multilingual and Crosslingual Focused Evaluation. In ACL. 1--14."},{"key":"e_1_2_1_13_1","doi-asserted-by":"publisher","DOI":"10.14778\/3484224.3484234"},{"key":"e_1_2_1_14_1","volume-title":"The Faiss library. CoRR abs\/2401.08281","author":"Douze Matthijs","year":"2024","unstructured":"Matthijs Douze, Alexandr Guzhva, Chengqi Deng, Jeff Johnson, Gergely Szilvasy, Pierre-Emmanuel Mazar\u00e9, Maria Lomeli, Lucas Hosseini, and Herv\u00e9 J\u00e9gou. 2024. The Faiss library. CoRR abs\/2401.08281 (2024)."},{"key":"e_1_2_1_15_1","unstructured":"Tianyu Gao Xingcheng Yao and Danqi Chen. 2021. SimCSE: Simple Contrastive Learning of Sentence Embeddings. In EMNLP. 6894--6910."},{"key":"e_1_2_1_16_1","first-page":"19","article-title":"The Cascades Framework for Query Optimization","volume":"18","author":"Graefe Goetz","year":"1995","unstructured":"Goetz Graefe. 1995. The Cascades Framework for Query Optimization. IEEE Data Eng. Bull. 18, 3 (1995), 19--29.","journal-title":"IEEE Data Eng. Bull."},{"key":"e_1_2_1_17_1","volume-title":"DeWitt","author":"Graefe Goetz","year":"1987","unstructured":"Goetz Graefe and David J. DeWitt. 1987. The EXODUS Optimizer Generator. In SIGMOD. 160--172."},{"key":"e_1_2_1_18_1","volume-title":"McKenna","author":"Graefe Goetz","year":"1993","unstructured":"Goetz Graefe and William J. McKenna. 1993. The Volcano Optimizer Generator: Extensibility and Efficient Search. In ICDE. 209--218."},{"key":"e_1_2_1_19_1","doi-asserted-by":"crossref","unstructured":"Yue Han Guoliang Li Haitao Yuan and Ji Sun. 2021. An Autonomous Materialized View Management System with Deep Reinforcement Learning. In ICDE. 2159--2164.","DOI":"10.1109\/ICDE51399.2021.00217"},{"key":"e_1_2_1_20_1","volume-title":"Survey of Hallucination in Natural Language Generation. ACM Comput. Surv. 55, 12","author":"Ji Ziwei","year":"2023","unstructured":"Ziwei Ji, Nayeon Lee, Rita Frieske, Tiezheng Yu, Dan Su, Yan Xu, Etsuko Ishii, Yejin Bang, Andrea Madotto, and Pascale Fung. 2023. Survey of Hallucination in Natural Language Generation. ACM Comput. Surv. 55, 12 (2023), 248:1--248:38."},{"key":"e_1_2_1_21_1","doi-asserted-by":"publisher","DOI":"10.14778\/2850583.2850594"},{"key":"e_1_2_1_22_1","doi-asserted-by":"publisher","DOI":"10.14778\/3352063.3352141"},{"key":"e_1_2_1_23_1","volume-title":"Fei Huang, Reynold Cheng, and Yongbin Li.","author":"Li Jinyang","year":"2023","unstructured":"Jinyang Li, Binyuan Hui, Ge Qu, Jiaxi Yang, Binhua Li, Bowen Li, Bailin Wang, Bowen Qin, Ruiying Geng, Nan Huo, Xuanhe Zhou, Chenhao Ma, Guoliang Li, Kevin Chen-Chuan Chang, Fei Huang, Reynold Cheng, and Yongbin Li. 2023. Can LLM Already Serve as A Database Interface? A BIg Bench for Large-Scale Database Grounded Text-to-SQLs. In NeurIPS."},{"key":"e_1_2_1_24_1","unstructured":"Xiaonan Li Kai Lv Hang Yan Tianyang Lin Wei Zhu Yuan Ni Guotong Xie Xiaoling Wang and Xipeng Qiu. 2023. Unified Demonstration Retriever for In-Context Learning. In ACL. 4644--4668."},{"key":"e_1_2_1_25_1","unstructured":"Andrew L. Maas Raymond E. Daly Peter T. Pham Dan Huang Andrew Y. Ng and Christopher Potts. 2011. Learning Word Vectors for Sentiment Analysis. In ACL. 142--150."},{"key":"e_1_2_1_26_1","unstructured":"Mayank Mishra Matt Stallone Gaoyuan Zhang Yikang Shen Aditya Prasad Adriana Meza Soria Michele Merler Parameswaran Selvam Saptha Surendran Shivdeep Singh Manish Sethi Xuan-Hong Dang Pengyuan Li Kun-Lung Wu Syed Zawad Andrew Coleman Matthew White Mark Lewis Raju Pavuluri Yan Koyfman Boris Lublinsky Maximilien de Bayser Ibrahim Abdelaziz Kinjal Basu Mayank Agarwal Yi Zhou Chris Johnson Aanchal Goyal Hima Patel S. Yousaf Shah Petros Zerfos Heiko Ludwig Asim Munawar Maxwell Crouse Pavan Kapanipathi Shweta Salaria Bob Calio Sophia Wen Seetharami Seelam Brian Belgodere Carlos A. Fonseca Amith Singhee Nirmit Desai David D. Cox Ruchir Puri and Rameswar Panda. 2024. Granite Code Models: A Family of Open Foundation Models for Code Intelligence. CoRR abs\/2405.04324 (2024)."},{"key":"e_1_2_1_27_1","doi-asserted-by":"crossref","unstructured":"Hamid Pirahesh Joseph M. Hellerstein and Waqar Hasan. 1992. Extensible\/Rule Based Query Rewrite Optimization in Starburst. In SIGMOD. 39--48.","DOI":"10.1145\/130283.130294"},{"key":"e_1_2_1_28_1","doi-asserted-by":"crossref","unstructured":"Nils Reimers and Iryna Gurevych. 2019. Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks. In EMNLP. 3980--3990.","DOI":"10.18653\/v1\/D19-1410"},{"key":"e_1_2_1_29_1","volume-title":"Toolformer: Language Models Can Teach Themselves to Use Tools. In NeurIPS.","author":"Schick Timo","year":"2023","unstructured":"Timo Schick, Jane Dwivedi-Yu, Roberto Dess\u00ec, Roberta Raileanu, Maria Lomeli, Eric Hambro, Luke Zettlemoyer, Nicola Cancedda, and Thomas Scialom. 2023. Toolformer: Language Models Can Teach Themselves to Use Tools. In NeurIPS."},{"key":"e_1_2_1_30_1","volume-title":"Quantifying Language Models' Sensitivity to Spurious Features in Prompt Design or: How I learned to start worrying about prompt formatting. CoRR abs\/2310.11324","author":"Sclar Melanie","year":"2023","unstructured":"Melanie Sclar, Yejin Choi, Yulia Tsvetkov, and Alane Suhr. 2023. Quantifying Language Models' Sensitivity to Spurious Features in Prompt Design or: How I learned to start worrying about prompt formatting. CoRR abs\/2310.11324 (2023)."},{"key":"e_1_2_1_31_1","volume-title":"SQL-PaLM: Improved Large Language Model Adaptation for Text-to-SQL. CoRR abs\/2306.00739","author":"Sun Ruoxi","year":"2023","unstructured":"Ruoxi Sun, Sercan \u00d6. Arik, Hootan Nakhost, Hanjun Dai, Rajarishi Sinha, Pengcheng Yin, and Tomas Pfister. 2023. SQL-PaLM: Improved Large Language Model Adaptation for Text-to-SQL. CoRR abs\/2306.00739 (2023)."},{"key":"e_1_2_1_32_1","volume-title":"LLaMA: Open and Efficient Foundation Language Models. CoRR abs\/2302.13971","author":"Touvron Hugo","year":"2023","unstructured":"Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timoth\u00e9e Lacroix, Baptiste Rozi\u00e8re, Naman Goyal, Eric Hambro, Faisal Azhar, Aur\u00e9lien Rodriguez, Armand Joulin, Edouard Grave, and Guillaume Lample. 2023. LLaMA: Open and Efficient Foundation Language Models. CoRR abs\/2302.13971 (2023)."},{"key":"e_1_2_1_33_1","unstructured":"Can Wang Sheng Jin Yingda Guan Wentao Liu Chen Qian Ping Luo and Wanli Ouyang. 2022. Pseudo-Labeled Auto-Curriculum Learning for Semi-Supervised Keypoint Localization. In ICLR."},{"key":"e_1_2_1_34_1","doi-asserted-by":"crossref","unstructured":"Zhaoguo Wang Zhou Zhou Yicun Yang Haoran Ding Gansen Hu Ding Ding Chuzhe Tang Haibo Chen and Jinyang Li. 2022. WeTune: Automatic Discovery and Verification of Query Rewrite Rules. In SIGMOD. ACM 94--107.","DOI":"10.1145\/3514221.3526125"},{"key":"e_1_2_1_35_1","volume-title":"Larger language models do in-context learning differently. CoRR abs\/2303.03846","author":"Wei Jerry W.","year":"2023","unstructured":"Jerry W. Wei, Jason Wei, Yi Tay, Dustin Tran, Albert Webson, Yifeng Lu, Xinyun Chen, Hanxiao Liu, Da Huang, Denny Zhou, and Tengyu Ma. 2023. Larger language models do in-context learning differently. CoRR abs\/2303.03846 (2023)."},{"key":"e_1_2_1_36_1","volume-title":"Factor Windows: Cost-based Query Rewriting for Optimizing Correlated Window Aggregates. In ICDE. 2722--2734.","author":"Wu Wentao","year":"2022","unstructured":"Wentao Wu, Philip A. Bernstein, Alex Raizman, and Christina Pavlopoulou. 2022. Factor Windows: Cost-based Query Rewriting for Optimizing Correlated Window Aggregates. In ICDE. 2722--2734."},{"key":"e_1_2_1_37_1","volume-title":"DB-GPT: Empowering Database Interactions with Private Large Language Models. CoRR abs\/2312.17449","author":"Xue Siqiao","year":"2023","unstructured":"Siqiao Xue, Caigao Jiang, Wenhui Shi, Fangyin Cheng, Keting Chen, Hongjun Yang, Zhiping Zhang, Jianshan He, Hongyang Zhang, Ganglin Wei, Wang Zhao, Fan Zhou, Danrui Qi, Hong Yi, Shaodong Liu, and Faqiang Chen. 2023. DB-GPT: Empowering Database Interactions with Private Large Language Models. CoRR abs\/2312.17449 (2023)."},{"key":"e_1_2_1_38_1","unstructured":"Shunyu Yao Jeffrey Zhao Dian Yu Nan Du Izhak Shafran Karthik R. Narasimhan and Yuan Cao. 2023. ReAct: Synergizing Reasoning and Acting in Language Models. In ICLR."},{"key":"e_1_2_1_39_1","unstructured":"Seonghyeon Ye Jiseon Kim and Alice Oh. 2021. Efficient Contrastive Learning via Novel Data Augmentation and Curriculum Learning. In EMNLP. 1832--1838."},{"key":"e_1_2_1_40_1","doi-asserted-by":"crossref","unstructured":"Haitao Yuan Guoliang Li Ling Feng Ji Sun and Yue Han. 2020. Automatic View Generation with Deep Learning and Reinforcement Learning. In ICDE. 1501--1512.","DOI":"10.1109\/ICDE48307.2020.00133"},{"key":"e_1_2_1_41_1","volume-title":"Wei Bi, Freda Shi, and Shuming Shi.","author":"Zhang Yue","year":"2023","unstructured":"Yue Zhang, Yafu Li, Leyang Cui, Deng Cai, Lemao Liu, Tingchen Fu, Xinting Huang, Enbo Zhao, Yu Zhang, Yulong Chen, Longyue Wang, Anh Tuan Luu, Wei Bi, Freda Shi, and Shuming Shi. 2023. Siren's Song in the AI Ocean: A Survey on Hallucination in Large Language Models. CoRR abs\/2309.01219 (2023)."},{"key":"e_1_2_1_42_1","doi-asserted-by":"publisher","DOI":"10.14778\/3529337.3529349"},{"key":"e_1_2_1_43_1","doi-asserted-by":"publisher","DOI":"10.14778\/3636218.3636235"},{"key":"e_1_2_1_44_1","doi-asserted-by":"publisher","DOI":"10.14778\/3636218.3636235"},{"key":"e_1_2_1_45_1","doi-asserted-by":"publisher","DOI":"10.14778\/3485450.3485456"},{"key":"e_1_2_1_46_1","volume-title":"R3-NL2GQL: A Hybrid Models Approach for for Accuracy Enhancing and Hallucinations Mitigation. CoRR abs\/2311.01862","author":"Zhou Yuhang","year":"2023","unstructured":"Yuhang Zhou, He Yu, Siyu Tian, Dan Chen, Liuzhi Zhou, Xinlin Yu, Chuanjun Ji, Sen Liu, Guangnan Ye, and Hongfeng Chai. 2023. R3-NL2GQL: A Hybrid Models Approach for for Accuracy Enhancing and Hallucinations Mitigation. CoRR abs\/2311.01862 (2023)."}],"container-title":["Proceedings of the VLDB Endowment"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/dl.acm.org\/doi\/pdf\/10.14778\/3696435.3696440","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2025,2,11]],"date-time":"2025-02-11T20:42:50Z","timestamp":1739306570000},"score":1,"resource":{"primary":{"URL":"https:\/\/dl.acm.org\/doi\/10.14778\/3696435.3696440"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2024,9]]},"references-count":46,"journal-issue":{"issue":"1","published-print":{"date-parts":[[2024,9]]}},"alternative-id":["10.14778\/3696435.3696440"],"URL":"https:\/\/doi.org\/10.14778\/3696435.3696440","relation":{},"ISSN":["2150-8097"],"issn-type":[{"value":"2150-8097","type":"print"}],"subject":[],"published":{"date-parts":[[2024,9]]},"assertion":[{"value":"2025-02-11","order":3,"name":"published","label":"Published","group":{"name":"publication_history","label":"Publication History"}}]}}