arXiv

Test-Time Optimization of Physical Query Plans with LLMs

Title: Enhancing Physical Query Plans via Test-Time Optimization Using Large Language Models

Abstract: Conventional query optimization depends on cost-based optimizers that forecast execution expenses—such as runtime, memory usage, and I/O—by leveraging statistical models and fixed heuristics. While refining these components demands significant engineering resources, they frequently fail to capitalize on semantic correlations within schemas and queries that could yield superior physical plans. In contrast, Large Language Models (LLMs) possess the ability to interpret column semantics, value distributions, and broader domain contexts, offering insights that classical statistical methods overlook.

This study presents DBPlanBench, a framework built on the DataFusion engine. This tool exposes physical plans via a compact serialized format and facilitates the application of edits proposed by LLMs as JSON patches. Leveraging this infrastructure, we implement a test-time optimization process: an LLM analyzes physical query plans and suggests targeted modifications grounded in semantic reasoning, while an evolutionary search algorithm iteratively refines these proposals. Our approach targets OLAP queries, where the high frequency of execution means that even marginal efficiency improvements result in significant cumulative cost reductions.

Our evaluation concentrates on join reordering and join-side selection, scenarios in which errors in cardinality estimation tend to multiply. The results indicate median speedups ranging from $1.10$ to $1.12\times$ on TPC-H and from $1.05$ to $1.07\times$ on TPC-DS, with certain queries experiencing speedups as high as $4.78\times$. Furthermore, we show that optimizations identified at smaller scale factors generalize effectively to larger ones, thereby validating a cost-efficient workflow that scales from small to large datasets.


Source: arXiv Generated at: 2026-06-03 00:00:00 UTC

Related Articles

TikTok Billionaire Tops Ambani as Asia’s Second-Richest
Bloomberg

TikTok Billionaire Tops Ambani as Asia’s Second-Richest

TikTok founder surpasses Mukesh Ambani to become Asia’s second-richest person, marking a significant shift in the region...

Publishers in UK can opt out of Google AI search results
BBC News

Publishers in UK can opt out of Google AI search results

UK publishers can now opt out of Google’s AI search summaries, a CMA ruling designed to boost their bargaining power and...

Kioxia Edges Nearer Toyota’s Market Cap in Shakeup to Japan Inc.
Bloomberg

Kioxia Edges Nearer Toyota’s Market Cap in Shakeup to Japan Inc.

Kioxia’s market cap nears Toyota’s, signaling a major shift in Japan’s corporate hierarchy. This narrowing gap highlight...

Reuters

Morning Bid: Marvell, a fitting name for the latest AI darling

Reuters highlights Marvell as a top AI stock, noting its name perfectly suits its status as the newest market darling.

Financial Times

Tim Hayward: I built the Jaguar E-Type of computer keyboards

Tim Hayward compares his bespoke keyboard designs to the Jaguar E-Type. He explores high-end customization for personal ...

Financial Times

AI Labs: Zuckerberg’s $100bn gamble

Meta’s $100 billion AI investment aims to secure AI dominance, but questions remain whether sheer spending can outpace c...