
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.