Query Rewriting via LLMs
Sriram Dharwada, Himanshu Devrani, Jayant Haritsa, Harish Doraiswamy

TL;DR
This paper explores leveraging LLMs for query rewriting to improve SQL query performance, combining prompts, rules, and verification tools, resulting in significant speedups over existing methods.
Contribution
It introduces LITHE, an LLM-based query rewriting system that integrates prompts, rules, and verification to enhance performance and correctness of complex SQL queries.
Findings
Achieved up to 13.2x speedup on TPC-DS benchmarks.
Outperformed state-of-the-art rewriters and native optimizers.
Demonstrated effectiveness on standard database platforms.
Abstract
When complex SQL queries suffer slow executions despite query optimization, DBAs typically invoke automated query rewriting tools to recommend ``lean'' equivalents that are conducive to faster execution. The rewritings are usually achieved via transformation rules, but these rules are limited in scope and difficult to update in a production system. Recently, LLM-based techniques have also been suggested, but they are prone to semantic and syntactic errors. We investigate here how the remarkable cognitive capabilities of LLMs can be leveraged for performant query rewriting while incorporating safeguards and optimizations to ensure correctness and efficiency. Our study shows that these goals can be progressively achieved through incorporation of (a) an ensemble suite of basic prompts, (b) database-sensitive prompts via redundancy removal and selectivity-based rewriting rules, and (c)…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsNatural Language Processing Techniques · Semantic Web and Ontologies
