BlogsTogether AILLM-Guided Database Query Optimization

LLM-Guided Database Query Optimization

LLM-Guided Database Query Optimization

1
posts
2026

Together AI is exploring the application of LLMs to optimize database query execution plans. This involves developing harnesses like DBPlanBench to expose query execution processes to LLMs, enabling them to analyze and suggest rewrites to improve performance. The approach focuses on semantic reasoning over statistical estimation, using techniques like JSON patching for targeted edits and evolutionary search for iterative refinement. The goal is to enhance query performance and reduce resource consumption without modifying the core database engine.

2026

AI for Systems: Using LLMs to Optimize Database Query Execution

4/3/2026

This post introduces DBPlanBench, a harness for Apache DataFusion that exposes its physical operator graph to LLMs for query optimization. It details a token-efficient JSON serialization layer for query plans, the use of JSON Patches for targeted LLM-generated edits, and an evolutionary plan patching approach for iterative refinement. The post also describes a method for transferring optimized plans across different data scales (SF3 to SF10) and presents empirical results showing significant speedups and resource reductions.