Pith. sign in

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 →

arxiv 2602.10387 v2 pith:JEDKI4YD submitted 2026-02-11 cs.DB cs.AI

Test-Time Optimization of Physical Query Plans with LLMs

classification cs.DB cs.AI
keywords query optimizationlarge language modelsphysical query plansevolutionary searchDataFusionjoin reorderingcardinality estimationtest-time optimization
verification ladder T0 review T1 audit T2 compute T3 formal T4 reserved

The pith

A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.

The paper tries to establish that LLMs, given a compact serialized physical plan and execution feedback, can discover faster query plans than an industrial-grade rule-based optimizer. It shows that evolutionary sampling over LLM-proposed JSON patches yields median speedups around 1.1× on TPC-H-derived and TPC-DS-derived workloads, occasional large speedups, and plans that transfer from small to larger data scales. If true, this would make test-time LLM optimization a practical complement to traditional cost-based optimizers, especially for repeated OLAP queries.

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.

Watch this falsifier. Get emailed when new claim-graph text bears on it.

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

These are editorial extensions of the paper, not claims the author makes directly.

  • 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.

Desk editor's note, referee report, simulated authors' rebuttal, and a circularity audit.

Referee Report

3 major / 5 minor

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)
  1. [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.
  2. [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.
  3. [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)
  1. [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.
  2. [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.
  3. [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.
  4. [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.
  5. [Section 7] Typo: 'derivated TPC-H and TPC-DS benchmarks' should be 'derived TPC-H and TPC-DS benchmarks'.

Circularity Check

0 steps flagged

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

3 free parameters · 5 axioms · 0 invented entities

The central claim rests on a self-generated workload, on the assumption that JSON-patch invariants preserve query semantics, and on the search budget. There are no fitted scientific parameters used to manufacture the result; the LLM is a black-box component whose semantic estimates are unmeasured. DBPLANBENCH is a software artifact, not an unexplained entity.

free parameters (3)
  • Evolution search population K and steps T = K=5, T=4
    Chosen by hand; larger budgets yield larger speedups, so the headline numbers depend on this search effort.
  • Query duration filter bounds = 0.15s to 15s
    Used to keep queries in a measurable regime; excludes short queries where patch overhead dominates and long queries that are expensive to explore, shaping the speedup distribution.
  • Workload shape: complexity levels and queries per level = 30 queries at each of complexities 5, 6, 7, 8 per dataset = 120 per dataset
    Hand-selected to control difficulty; the distribution of speedups is specific to this workload shape.
axioms (5)
  • domain assumption The compact JSON serialization preserves all optimization-relevant semantics of the physical plan.
    Section 2.1; if information needed for correct patching is dropped, output-equality checks catch some but not all issues.
  • domain assumption Enforcing invariants (preserve all nodes, valid DAG topology, updated projections/join conditions) keeps patched plans semantically equivalent.
    Section 3.1; empirically checked per candidate by output comparison, but not proven for all possible patches.
  • ad hoc to paper GPT-5's semantic cardinality estimates are accurate enough to guide the search toward better plans.
    Section 3.1 instructs the model to reason semantically, but the paper does not directly measure estimation error or ablate against random/non-semantic patches.
  • domain assumption LLM-generated queries over TPC schemas represent typical OLAP workloads.
    Section 4 constructs the workload with GPT-5 and filters it; generalizing to real OLAP depends on this representativeness.
  • domain assumption Minimum-of-50 sandbox latencies is an unbiased estimate of noise-free runtime.
    Section 3.3 and Appendix B.1 support it with CoV analysis, but it relies on a right-skewed noise model for sandbox measurements.

pith-pipeline@v1.3.0-alltime-deepseek · 24961 in / 12495 out tokens · 126285 ms · 2026-08-03T01:07:14.713797+00:00 · methodology

0 comments
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

Figures reproduced from arXiv: 2602.10387 by Ciro Greco, Federico Bianchi, Jacopo Tagliabue, James Zou, Mehmet Hamza Erol, Xiangpeng Hao.

Figure 1
Figure 1. Figure 1: Semantic-aware Join Optimization. By identifying the high selectivity of the ‘date’ predicate, the plan can be reordered to prune data early, significantly reducing the cardinality of the subsequent JOIN. We explore this use case in Section 5. Given their success in similar settings, it is therefore natu￾ral to ask: can LLMs discover better physical plans when compared to algorithms crafted by human expert… view at source ↗
Figure 2
Figure 2. Figure 2: DBPLANBENCH, provides accessible APIs to extract a physical plan that an LLM can edit. This plan can be then executed in DataFusion as if it was a native DataFusion plan. detailed type encodings, repeated per-partition metadata, and other execution-specific details that are both irrelevant to optimization and expensive in LLM context. Feeding such data directly to an LLM is inefficient and quickly ex￾haust… view at source ↗
Figure 3
Figure 3. Figure 3: Visualization of the evolutionary algorithms applied. 3. Optimizing Query Plans with LLMs We optimize physical plans with LLMs relying on their ability to reason and apply semantics-aware transforma￾tions. We use GPT-5 as our optimization model, ask it to (i) analyze a given physical plan node-by-node, (ii) esti￾mate intermediate cardinalities using semantic knowledge of schemas and predicates, and (iii) g… view at source ↗
Figure 4
Figure 4. Figure 4: CCDF Plots Representing the Change in the Distribution Throughout the Evolution. BoL-Evol results are plotted for TPC-H and PST-Evol results are plotted for the TPC-DS. The y-axis (fastx(t)) is in the log-scale. We observe diminishing returns when the step is larger. Moreover, evolutionary algorithms help pushing the frontier in achieving higher speedups in contrast to base sampling. produces the same outp… view at source ↗
Figure 5
Figure 5. Figure 5: Plan-transfer generalization across scale factors. Scat￾ter of speedup at large scale vs. small scale under the new method. The diagonal indicates parity (y = x). However, the LLM uses semantic reasoning to infer that a single year in a century-scale dimension is highly selective, making date dim the most effective filter to apply first. The optimization process identifies this opportunity and rewires the … view at source ↗
Figure 6
Figure 6. Figure 6: External verification of reported speedups. For each dataset, we re-execute the top-30 optimizations (by reported speedup) in a static, bare-metal environment. Each point compares a query’s reported speedup to its re-measured speedup. We verify that the top reported results largely remain speedups under re-measurement (most points above y = 1) and are broadly centered around y = x, supporting the validity … view at source ↗
Figure 7
Figure 7. Figure 7: Footprint ratios vs. speedup. For each dataset’s top-30 optimizations (by speedup), we plot the relationship between speedup and the ratio (base over optimized plan) under orthogonal and platform-stable footprint metrics for HashJoin operators: build memory used (sum/max) and output rows (sum). Ratios > 1 indicate reductions under the optimized plans, supporting and helping explain the reported speedups. 5… view at source ↗
Figure 8
Figure 8. Figure 8: Prompt length vs. speedup. Scatter plot of user prompt length (characters; log-scale) versus achieved speedup, with fitted linear trends for TPC-DS and pooled data (TPC-DS: Pearson r=− 0.14, Spearman ρ= − 0.275; pooled: ρ= − 0.26), indicating a weak negative association between prompt length and achieved speedup. DataFusion’s internal execution representation, or fail mid￾execution. While less frequent, we… view at source ↗
Figure 9
Figure 9. Figure 9: Complexity vs. Runtime. We observe an increasing trend: the higher the complexity, the longer a query runs. 0 20 40 60 80 100 Percentage of Candidate Optimizations 5 6 7 8 Complexity TPCH (w/ BoL-Evol) 0 20 40 60 80 100 Percentage of Candidate Optimizations TPCDS (w/ PST-Evol) Invalid Patch Server-Side Execution Error Plan Deserialization Error Empty Patch Plan Execution Error Successful Execution (Non-Emp… view at source ↗
Figure 10
Figure 10. Figure 10: Complexity vs. optimization outcomes. Stacked bars show the breakdown of candidate outcomes across query complexities for TPC-H (BoL-Evol) and TPC-DS (PST-Evol). 5 6 7 8 Complexity 50k 100k 200k 500k User prompt length (chars, log) TPC-H p90 p50 5 6 7 8 Complexity TPC-DS [PITH_FULL_IMAGE:figures/full_fig_p015_10.png] view at source ↗
Figure 11
Figure 11. Figure 11: Complexity vs. User Prompt Length. We observe an increasing trend for the length of the User Prompt employed during optimization of the physical plans. The format could be seen in Section E.3.2. The length of prompts for the TPC-DS is notably longer than those for TPC-H. 15 [PITH_FULL_IMAGE:figures/full_fig_p015_11.png] view at source ↗
Figure 12
Figure 12. Figure 12: Complexity vs. Speedup. We observe that in TPC-H, there is a slight increase in speedup with respect to complexity, whereas in TPC-DS, there is a visible inverse correlation. 1 1.05 1.1 1.2 1.3 1.4 1.5 Speedup 0% 25% 50% 75% 100% fast_x(t) TPC-H Best-Of t=1 t=2 t=3 t=4 1 1.05 1.1 1.2 1.3 1.4 1.5 Speedup 0% 25% 50% 75% 100% TPC-DS Best-Of t=1 t=2 t=3 t=4 [PITH_FULL_IMAGE:figures/full_fig_p016_12.png] view at source ↗
Figure 13
Figure 13. Figure 13: Linear Y-axis Version of the CCDF Plots in [PITH_FULL_IMAGE:figures/full_fig_p016_13.png] view at source ↗
Figure 14
Figure 14. Figure 14: Join-graph digest for the top query in TPC-DS. Node IDs in parentheses match the physical-plan JSON. 22 [PITH_FULL_IMAGE:figures/full_fig_p022_14.png] view at source ↗

discussion (0)

Sign in with ORCID, Apple, or X to comment. Anyone can read and Pith papers without signing in.

Forward citations

Cited by 1 Pith paper

Reviewed papers in the Pith corpus that reference this work. Sorted by Pith novelty score.

  1. From Custom-Fit to Portable: Bridging the Gap Between Synthesized and Engineered GPU Query Execution

    cs.DB 2026-07 conditional novelty 7.0

    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

11 extracted references · cited by 1 Pith paper

  1. [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. [2]

    Maintain valid DAG topology (no cycles, valid references)

  3. [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...

  4. [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...

  5. [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...

  6. [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...

  7. [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...

  8. [59]

    cr_ret 60ONcr_ret.cr_item_sk = cs.cs_item_sk 61ANDcr_ret.cr_order_number = cs.cs_order_number

  9. [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

  10. [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...

  11. [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...