From the source
Databricks reports that a prototype LLM agent beat its own query optimizer on join ordering in 80% of benchmark cases, cutting query latency by 1.3x overall.
- The work, a research collaboration with UPenn, targets a decades-old database problem: cardinality estimation is hard, and the number of possible join plans grows exponentially with the number of tables, so optimizers often pick poor orderings.
- The agent acts like an offline experimenter rather than sitting in the optimizer's hot path, which must choose join orders in a few hundred milliseconds.
- It has one tool that executes a candidate join order and returns its runtime, capped at the original query's runtime, plus the size of each computed subplan.
- The agent ran 50 iterations per query, free to exploit promising plans or explore risky ones, and structured model outputs force every tool call to produce a valid join reordering.
- Evaluation used the Join Order Benchmark, whose IMDb dataset was scaled up by duplicating each row 10 times, with 15 rollouts per query across all 113 queries.





