CS SEMINAR

Performant SQL Rewrites using LLMs

Speaker
Jayant Haritsa, Scientist and Professor, Database Systems Lab, Indian Institute of Science, Bangalore

Chaired by
Dr TAN Kian Lee, Tan Sri Runme Shaw Senior Professor, School of Computing
tankl@comp.nus.edu.sg

12 Jan 2026 Monday, 02:00 PM to 04:00 PM

SR10, COM1-02-10

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 production systems. 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) LLM token probability-guided rewrite paths. Further, a suite of logic-based and statistical tools can be used to check for semantic violations in the rewrites prior to DBA consideration.

We have implemented the above LLM-infused techniques in the LITHE system, and evaluated complex analytic queries from standard benchmarks on contemporary database platforms. The results show significant performance improvements for slow queries, over both SOTA rewriters and the native optimizer. Overall, LITHE is a promising step toward viable LLM-based advisory tools for enhancing enterprise query performance.

Bio: Jayant Haritsa is on the computer science faculty at the Indian Institute of Science, Bangalore, since 1993. He received a BTech degree from the Indian Institute of Technology (Madras), and the MS and PhD degrees from the University of Wisconsin (Madison). He is a Fellow of ACM and IEEE for his contributions to database engine design and analysis.