REVIEW 3 major objections 5 minor 1 cited by
LLM-proposed, execution-verified plan patches beat DataFusion's optimizer, with median 1.1× speedups and up to 4.78×.
Reviewed by Pith at T0; open to challenge. T0 means a machine referee read the full paper against a public rubric. the ladder, T0–T4 →
T0 review · deepseek-v4-flash
2026-08-03 01:07 UTC pith:JEDKI4YD
load-bearing objection A solid empirical contribution with a real workload-representativeness gap; the speedups are measured carefully but on queries the LLM itself generated, so the headline numbers should be read as upper bounds. the 3 major comments →
Test-Time Optimization of Physical Query Plans with LLMs
The pith
A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.
Core claim
The paper claims that a physical execution plan produced by DataFusion's optimizer can be improved after the fact: serialize the plan, have an LLM propose localized JSON-patch edits guided by semantic cardinality estimates, and evolve the best candidates using measured execution time as the fitness function. Across 240 synthetic TPC-H/TPC-DS queries, median speedups reach 1.10–1.12× (TPC-H) and 1.05–1.07× (TPC-DS), with up to 4.78× on one TPC-DS query. The mechanism is join reordering and build-side swapping that reduce intermediate cardinalities.
What carries the argument
DBPlanBench, a harness that serializes DataFusion physical plans into a compact, token-efficient JSON representation, applies LLM-generated RFC-6902 JSON patches to rewire the plan, and executes the patched plans to verify correctness and measure runtime. Two evolutionary sampling strategies (Best-of-Last and Parallel Single-Thread) refine candidate patches across iterations, using execution-based fitness to select the fastest valid plan.
Load-bearing premise
The generated benchmark queries contain the kind of selective predicates and dimension/fact join patterns where semantic reasoning helps; if actual workloads are less structured, the median gains could shrink or disappear.
What would settle it
Run the identical pipeline on the official TPC-H and TPC-DS query suites: if median speedup over DataFusion is at or below 1.0, the claimed out-performance is an artifact of the generated workload rather than a general property.
If this is right
- Even modest per-query speedups compound for repeated OLAP workloads, making test-time optimization economically worthwhile.
- Optimizations found at a small scale factor transfer to larger scale factors, supporting a low-cost discovery-then-lift workflow.
- Semantic cardinality estimation by LLMs can catch systematic errors that statistical heuristics make, e.g., when correlated predicates such as year = 2001 are highly selective.
- The approach requires only localized structural edits, reducing token cost and preserving plan correctness through invariants and output-equivalence checking.
Where Pith is reading between the lines
- The speedup estimates may not extend to canonical TPC-H/TPC-DS queries or real production workloads, since the eval suite is LLM-generated and filtered by runtime.
- A random-patch control would isolate whether the gains come from semantic reasoning or from blind search through valid plan mutations; the paper does not include one.
- The same harness could be applied to other engines or to other plan-level decisions (e.g., join algorithms, parallelism) beyond the two edit types studied.
- Because the approach is test-time and query-specific, it could be combined with learned cardinality models or adaptive query processing without modifying the core optimizer.
Editorial analysis
A structured set of objections, weighed in public.
Referee Report
Summary. The paper introduces DBPlanBench, a harness for Apache DataFusion that serializes physical query plans into a compact JSON representation, lets an LLM (GPT-5) propose localized JSON-patch edits, and uses evolutionary search (PST-Evol and BoL-Evol) with execution feedback to refine candidates. The evaluation is on GPT-5-generated SQL workloads over TPC-H and TPC-DS schemas, with correctness enforced by output-equivalence checks and timings aggregated as min-of-50 sandbox runs. The main claim is that LLM-proposed, execution-verified plan patches can outperform DataFusion's default optimizer, with median speedups of 1.10–1.12x on TPC-H and 1.05–1.07x on TPC-DS, up to 4.78x, and that optimizations found at scale factor 3 transfer to scale factor 10.
Significance. If the result holds, the paper makes a useful empirical contribution to test-time query-plan optimization: it provides a practical serialization and patching interface for DataFusion plans, a careful execution protocol, and evidence that an LLM-guided search can discover non-obvious join reorderings and build-side selections. The strongest parts are the measurement discipline—50 sandbox runs per plan, min-of-R timing, output-equivalence checks, an external bare-metal re-execution of the top-30 plans, and a join-footprint analysis—which make the reported speedups credible within the tested workload. The work is also reproducible in principle through the promised open-source release. However, the significance for real OLAP workloads is currently limited by the use of LLM-generated, runtime-filtered queries rather than canonical TPC-H/TPC-DS query suites, and by the absence of a non-semantic control baseline.
major comments (3)
- [Section 4, Query Suite Construction] The central numerical claims are computed on 120 GPT-5-generated queries per dataset over TPC-H/TPC-DS schemas, filtered to queries running between 0.15s and 15s. This is not the official TPC-H/TPC-DS query suite, yet the abstract and Section 5 phrase the results as 'on TPC-H' and 'on TPC-DS'. The filter and generator may select for queries with particularly LLM-friendly semantic patterns (e.g., selective date predicates and dimension/fact joins) and for optimizer blind spots. Please evaluate at least the official 22 TPC-H and 99 TPC-DS queries, or alternatively provide a distributional comparison (join graphs, predicate selectivities, plan shapes) between the generated workload and the canonical suites, and hedge the claims accordingly.
- [Section 3.4 and Table 1] There is no random-patch or mutation-only baseline. The Best-of baseline controls for the number of LLM samples but not for whether the LLM's semantic reasoning contributes anything beyond a broad search over valid plan variants. To support the Section 5 claim that 'LLMs use semantic knowledge to optimize plans', add a control that performs the same evolutionary search using randomized but valid plan mutations (e.g., random join swaps and side flips) with the same budget, output-equivalence checks, and timing protocol. If random mutations achieve comparable speedups, the semantic-cardinality explanation is unsupported; if they do not, the causal claim would be substantially strengthened.
- [Section 5 vs. Table 1] There is a direct inconsistency in the reported medians. Section 5 states that 'median speedups are around 1.15x–1.2x for TPC-H and around 1.1x for TPC-DS', but Table 1 reports P50 values of 1.10–1.12x for TPC-H and 1.05–1.07x for TPC-DS for the same final round. The abstract follows Table 1. This must be reconciled; if the prose refers to a different statistic, algorithm, or subset, that should be stated explicitly.
minor comments (5)
- [Abstract and Section 4] The wording 'on TPC-H and TPC-DS' should be replaced with 'on queries generated over TPC-H/TPC-DS schemas' or a similar qualifier, to avoid implying evaluation on the official benchmark query sets.
- [Figure 4] The caption shows BoL-Evol for TPC-H and PST-Evol for TPC-DS without explaining why different algorithms are used for the two datasets. Clarify the selection rule, or report both algorithms on both datasets.
- [Table 1] The caption should state the number of queries that remain after the 0.15s–15s filtering step, since 120 per dataset was the pre-filter target. The table headers also use Q and T without defining them in the caption; define Q as the query set and T as the evolution horizon.
- [Section B.2] The external verification only re-executes the top-30 queries per dataset. State explicitly that this validates the head of the distribution and does not verify the full set of speedups, and discuss whether the untested tail could be affected by selection bias.
- [Section 7] Typo: 'derivated TPC-H and TPC-DS benchmarks' should be 'derived TPC-H and TPC-DS benchmarks'.
Circularity Check
No significant circularity: the central speedup claims are execution-measured against the DataFusion baseline, not derived from fitting or from self-cited premises.
full rationale
The paper's claim chain is empirical rather than derivational. Physical plans are serialized (Section 2.1), patched by an LLM (Section 3.1), executed in sandboxes, validated by output equality, and timed with min-of-50 (Section 3.3); speedup_q(t)=tau(p0)/tau(p*_t) is a measured ratio, not an identity. The LLM is prompted to do semantic cardinality estimation, but that is an instruction, not a fitted parameter, and the final evidence is actual runtime on a fixed baseline plus external re-execution (Appendix B.2). Self-citations (e.g., Cheng et al. 2025, Yuksekgonul et al. 2025/2026, Tagliabue et al. 2024) support framing and related work only; none supplies a load-bearing premise or a uniqueness theorem that forces the paper's conclusions. The GPT-5-generated, runtime-filtered workload (Section 4) is a validity limitation—representativeness of real OLAP workloads is unestablished—but it does not make any result equivalent to its inputs by construction. The absence of a random-patch control weakens the attribution of speedups to semantic reasoning, yet the speedups themselves are measured against an external engine and would remain observable under any hypothesized mechanism. No equation is reused as its own output, and no fitted value is renamed as a prediction.
Axiom & Free-Parameter Ledger
free parameters (3)
- Evolution search population K and steps T =
K=5, T=4
- Query duration filter bounds =
0.15s to 15s
- Workload shape: complexity levels and queries per level =
30 queries at each of complexities 5, 6, 7, 8 per dataset = 120 per dataset
axioms (5)
- domain assumption The compact JSON serialization preserves all optimization-relevant semantics of the physical plan.
- domain assumption Enforcing invariants (preserve all nodes, valid DAG topology, updated projections/join conditions) keeps patched plans semantically equivalent.
- ad hoc to paper GPT-5's semantic cardinality estimates are accurate enough to guide the search toward better plans.
- domain assumption LLM-generated queries over TPC schemas represent typical OLAP workloads.
- domain assumption Minimum-of-50 sandbox latencies is an unbiased estimate of noise-free runtime.
read the original abstract
Traditional query optimization relies on cost-based optimizers that estimate execution cost (e.g., runtime, memory, and I/O) using predefined heuristics and statistical models. Improving these requires substantial engineering effort, yet they often cannot exploit semantic correlations in queries and schemas that could enable better physical plans. Large language models (LLMs), however, can reason about column semantics, value distributions, and broader domain context that classical statistics miss. We introduce DBPlanBench, a harness for the DataFusion engine that exposes physical plans through a compact serialized representation and applies LLM-proposed edits as JSON patches. On this harness, we instantiate a test-time optimization workflow where an LLM examines physical query plans, proposes localized edits based on semantic reasoning, and an evolutionary search refines the candidates across iterations. We target OLAP queries, where heavy, repeated execution turns even small efficiency gains into substantial cumulative savings. We specifically focus our evaluation on join reordering and join-side selection, where cardinality-estimation errors compound multiplicatively. Median speedups reach $1.10$-$1.12\times$ on TPC-H and $1.05$-$1.07\times$ on TPC-DS, with some achieving up to $4.78\times$. We also demonstrate that optimizations discovered at small scale factors transfer effectively to larger ones, supporting a low-cost small-to-large workflow.
Figures
Forward citations
Cited by 1 Pith paper
-
From Custom-Fit to Portable: Bridging the Gap Between Synthesized and Engineered GPU Query Execution
LLM-synthesized GPU query kernels outperform engineered engines by 7.4x, but a portable SYCL engine with lifted optimizations closes the gap to 1.27x, suggesting engineering remains preferable on GPUs.
Reference graph
Works this paper leans on
-
[1]
There are no redundant nodes in the plan
Preserve all nodes, do not remove nodes or leave nodes that are not connected to something. There are no redundant nodes in the plan
-
[2]
Maintain valid DAG topology (no cycles, valid references)
-
[3]
op": "replace
Update metadata when making structural changes - when swapping nodes or reordering joins, ensure that any associated metadata is also updated to reflect the new structure, including join keys/conditions and projection indexes (see below). **Update Projection Index After Swapping Join Inputs** When you swap the left and right inputs of a HashJoin, you MUST...
-
[22]
* ss.ss_net_paid 23)ASincome_weighted_paid 24FROMstore_sales ss 25JOINdONss.ss_sold_date_sk = d.d_date_sk 26LEFT JOINhousehold_demographics hdON ss.ss_hdemo_sk = hd.hd_demo_sk 27LEFT JOINincome_band ibON hd.hd_income_band_sk = ib.ib_income_band_sk 28GROUP BY1,2,3,4 29UNION ALL 30SELECT 31'web'::textASchannel, 32ws.ws_item_skASitem_sk, 33d.d_year, 34d.d_qo...
-
[23]
sr_ret 24ONsr_ret.sr_item_sk = ss.ss_item_sk 25ANDsr_ret.sr_ticket_number = ss.ss_ticket_number 26 27UNION ALL 28 29SELECT 30'web'::textASchannel, 31ws.ws_sold_date_skASsold_date_sk, 32ws.ws_item_skASitem_sk, 33ws.ws_bill_addr_skASaddr_sk, 34ws.ws_net_paidASsales_amt, 35wr_ret.return_amtASreturn_amt 36FROMweb_sales ws 37LEFT JOIN( 38SELECTwr_item_sk, wr_o...
-
[41]
wr_ret 42ONwr_ret.wr_item_sk = ws.ws_item_sk 43ANDwr_ret.wr_order_number = ws.ws_order_number 44 45UNION ALL 46 47SELECT 48'catalog'::textASchannel, 49cs.cs_sold_date_skASsold_date_sk, 50cs.cs_item_skASitem_sk, 51cs.cs_bill_addr_skASaddr_sk, 52cs.cs_net_paidASsales_amt, 53cr_ret.return_amtASreturn_amt 54FROMcatalog_sales cs 55LEFT JOIN( 56SELECTcr_item_sk...
-
[46]
* ws.ws_net_paid 47)ASincome_weighted_paid 48FROMweb_sales ws 49JOINdONws.ws_sold_date_sk = d.d_date_sk 50LEFT JOINhousehold_demographics hdON ws.ws_bill_hdemo_sk = hd.hd_demo_sk 51LEFT JOINincome_band ibON hd.hd_income_band_sk = ib.ib_income_band_sk 52GROUP BY1,2,3,4 53UNION ALL 54SELECT 55'catalog'::textASchannel, 56cs.cs_item_skASitem_sk, 57d.d_year, 5...
-
[59]
cr_ret 60ONcr_ret.cr_item_sk = cs.cs_item_sk 61ANDcr_ret.cr_order_number = cs.cs_order_number
-
[62]
s 63JOINitem iONi.i_item_sk = s.item_sk 64JOINcustomer_address caONca.ca_address_sk = s.addr_sk 65JOINdate_dim dONd.d_date_sk = s.sold_date_sk 18 Making Databases Faster with LLM Evolutionary Sampling 66WHEREd.d_year = 2001 67AND( 68SELECT COUNT( *) 69FROMwarehouse w 70WHEREw.w_state = ca.ca_state
2001
-
[70]
Sale- sUnion
* cs.cs_net_paid 71)ASincome_weighted_paid 72FROMcatalog_sales cs 73JOINdONcs.cs_sold_date_sk = d.d_date_sk 74LEFT JOINhousehold_demographics hdON cs.cs_bill_hdemo_sk = hd.hd_demo_sk 75LEFT JOINincome_band ibON hd.hd_income_band_sk = ib.ib_income_band_sk 76GROUP BY1,2,3,4 77), 78returns_channelAS( 79SELECT 80'store'::textASchannel, 81sr.sr_item_skASitem_s...
2001
-
[71]
>= 2 72GROUP BY 73d.d_year, 74s.channel, 75ca.ca_state, 76i.i_category 77HAVING 78SUM(s.sales_amt) >CAST(100000AS decimal(12,2)) 79AND COALESCE(SUM(s.return_amt), 0) < SUM(s.sales_amt) * 0.1 80ORDER BY 81d.d_year, 82s.channel, 83ca.ca_state, 84i.i_category A Query with Complexity 8 1WITHdAS( 2SELECTd_date_sk, d_year, d_qoy 3FROMdate_dim 4), 5sales_channel...
discussion (0)
Sign in with ORCID, Apple, or X to comment. Anyone can read and Pith papers without signing in.