Performant SQL Rewrites using LLMs
summary
System called LITHE rewrites SQL for PostgreSQL using an ensemble of prompts, database-aware rules like selectivity-guided rewriting, and token-probability driven search (token-probability MCTS), then runs syntax and semantic checks before DBA review. On TPC-DS (99 queries) LITHE finds 26 productive rewrites (>=50% faster), reports a geometric-mean optimizer-cost speedup ≈11.8 and measured time speedup ≈13.2; one rewrite yields ~6,500× improvement. Uses GPT-class LLMs for generation and combined statistical and provable verification to catch semantic errors.
AI-written summary · about
chapters (18)
- 0:00Introduction and welcome
- 1:31LLMs for SQL performance
- 8:53Postgres query processor overview
- 12:46SQL rewriting challenges
- 20:14LLM-based query rewrite system
- 25:30Prompting strategies for LLMs
- 27:55Benchmarking with TPC-DS
- 31:27Database knowledge in prompts
- 34:14Selectivity-guided rewrites
- 37:00Handling LLM uncertainty
- 39:30Monte Carlo tree search demo
- 41:41Verifying semantic equivalence
- 43:04Statistical vs provable verification
- 45:51Sample database techniques
- 47:18Plan-based equivalence checks
- 49:02Mutation-based testing
- 50:29TPC-DS benchmark results
- 52:36Conclusion and future work
related talks
29mRevolutionizing Text Transformation.
15mFrom Words to Data: Using LLMs to Turn Questions into SQL
50mImproving Postgres' Efficiency
41mHow types can turn a SQL interpreter into a SQL compiler
30mLLM Query Benchmarks: Cypher vs SQL
21mFrom Data to Precision: Fine-Tuning LLMs for Proprietary Query Languages
26mReverse Engineering Using LLMs
13mWriting an Interpreter in SQL for Fun and No Profit!
