<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>PAR2QO: Parametric Penalty-Aware Robust Query Optimization</title></titleStmt>
			<publicationStmt>
				<publisher>VLDB Endowment</publisher>
				<date>07/01/2025</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10690352</idno>
					<idno type="doi">10.14778/3749646.3749711</idno>
					<title level='j'>Proceedings of the VLDB Endowment</title>
<idno>2150-8097</idno>
<biblScope unit="volume">18</biblScope>
<biblScope unit="issue">11</biblScope>					

					<author>Haibo Xiu</author><author>Yang Li</author><author>Qianyu Yang</author><author>Pankaj K Agarwal</author><author>Jun Yang</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[<p>Parametric Query Optimization (PQO) is an important problem in database systems, yet existing approaches suffer from high training costs, sensitivity to estimation errors, and vulnerability to severe performance regressions. This paper introduces PAR<sup>2</sup>QO (PARametric Penalty-Aware Robust Query Optimization), a system that integrates robust query optimization into PQO. PAR<sup>2</sup>QO strategically obtains plans from a well-balanced set of probe locations informed by the workload, and caches them as plan-penalty profiles. At runtime, PAR<sup>2</sup>QO selects the plan with the lowest expected penalty, explicitly accounting for selectivity uncertainties. Extensive experiments show that PAR<sup>2</sup>QO delivers significant speedups over existing methods while ensuring robustness against performance degradation. Additionally, we introduce<bold>CARVER</bold>, a workload generator aimed at covering possible cardinalities of subqueries. Not only does CARVER provide a more comprehensive way to evaluate PQO methods, but when used for training learned methods, it can also enhance their generalizability and stability.</p>]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1">INTRODUCTION</head><p>A long-standing challenge in databases is Robust Query Optimization (RQO) <ref type="bibr">[12]</ref>. Query optimizers rely on selectivity and cost estimates to pick execution plans. When these estimates are inaccurate, the chosen plan can perform far worse than the optimal. There are various approaches towards robust query optimization; we focus on finding a robust query plan in this work: Instead of minimizing the plan cost given the estimated selectivities, which can be wrong, we look for a plan that "performs well" despite uncertainties in the estimates. In other words, when executed at the true selectivities, the plan is expected to incur a low penalty with respect to the cost of the true optimal plan. The resulting optimization problem is challenging because we must consider possible estimation errors and compare with the real optimal plans at the corrected selectivities, which amounts to exploring a neighborhood -rather than a single point -in the selectivity space. The optimization overhead can thus be higher than that for traditional query optimization.</p><p>Parametric Query Optimization (PQO) is a technique originally motivated by the desire to reduce optimization overhead for queries that follow the same template but differ in their parameter settings, which frequently arise in applications. Once PQO finds the optimal plan for a given query instance, it caches the plan and reuses it for future query instances whose estimated selectivities are close to the cached plan. Pushing the idea further, Kepler <ref type="bibr">[15]</ref>, the latest state of the art in PQO, employs deep learning to train a model that selects the right plan among a set of cached candidates.</p><p>Combining PQO and RQO is natural, because PQO helps to amortize query optimization overhead across multiple query instances. The potential of this combination was demonstrated in the recent RQO work of PARQO <ref type="bibr">[46]</ref>, which considered caching one robust plan per query template. However, opportunities for such reuses are limited because the choice of the robust plan varies across the selectivity space. There are better ways to reuse the computation in RQO: intuitively, RQO explores the neighborhood of each query instance; even if two query instances are not close enough to justify the same robust plan, the work of exploring their neighborhoods can still be shared.</p><p>Existing PQO approaches, on the other hand, are not designed to find robust plans. Some approaches have heuristics that favor caching plans that tend to be robust, e.g., plans that are close to being optimal at multiple points in the selectivity space. However, these approaches do not consider robustness when selecting plans at runtime. Furthermore, their ability to cache a robust plan depends heavily on what candidates were considered for caching in the first place. As a result, their candidate plans are either too focused on training queries (e.g., <ref type="bibr">[40]</ref>) without accounting for errors in selectivity estimates, too spread across the entire selectivity space (e.g., <ref type="bibr">[13]</ref>), and/or very expensive to acquire (e.g., Kepler <ref type="bibr">[15]</ref>, or <ref type="bibr">[13]</ref> in high dimensions).</p><p>To overcome these limitations, we propose a new PQO system, PAR 2 QO (PARametric Penalty-Aware Robust Query Optimization). This work differs from classical PQO approaches, which primarily aim to amortize optimization overhead by caching point-wise optimal plans, without properly accounting for robustness. It also distinguishes itself from traditional RQO approaches, which focus on finding a single robust plan for a given query instance, without considering reuse opportunities across the broader selectivity space. PAR 2 QO combines both: it aims to produce robust plans as RQO, but leveraging PQO to amortize optimization overhead. Importantly, PAR 2 QO offers a systematic treatment of robustness, guided by a formal definition and development of new PQO and RQO techniques to enable their efficient integration. It is practical to deploy, requiring only non-intrusive access to existing query optimizers and reasonable training and setup time. It also makes its decisions in a transparent manner, with no "black-boxing, " which is easy to understand and debug. Specifically, we make the following technical contributions in this paper: &#8226; PAR 2 QO employs a novel method to sample the selectivity space to acquire candidate plans. Leveraging the training workload and a learned model of selectivity estimation errors, PAR 2 QO is able to focus on the most relevant regions of the selectivity space -not only points corresponding to the estimated selectivities of training queries, but also in the neighborhoods induced by uncertainty in these estimates. &#8226; PAR 2 QO uses a novel caching strategy in the form of planpenalty profiles, for a carefully selected subset of candidate plans. Instead of caching only the plans themselves, this data structure also caches their cost profiles at sampled selectivities, which allows the best robust plan to be computed at runtime, using a rigorously defined robustness objective. Instead of relying on a black box to predict the most robust plan, the optimization decision is explainable using the error model, plan profiles, and robustness objective. &#8226; By focusing its learning efforts on selectivity errors observed from training queries, PAR 2 QO uses only a tiny fraction of the training cost of Kepler. PAR 2 QO's learned error model informs the generation of candidate plans at preparation time and plan selection at runtime, and is able to achieve better query performance than Kepler despite shorter training time. &#8226; In the process of evaluating our approach and others, we observed that standard benchmarks such as JOB <ref type="bibr">[27]</ref> and DSB <ref type="bibr">[11]</ref> are lacking in the PQO setting, because they either offer no guidance on how to generate parameter settings for a query template, or generate them from simple distributions that fail to stress-test PQO. Therefore, we propose a new query workload generator, CARVER (CARdinality coVERage), aimed at generating queries to provide good coverage of the range of possible subquery cardinalities that the optimizer might encounter. When used as training workloads, CARVER also improves the robustness of PQO and its ability to generalize to new workloads. Overall, by defining the robust optimization objective clearly and designing methods accordingly, PAR 2 QO is able to guard against query performance degradations due to selectivity errors and deliver better overall query performance than previous approaches. Experiments show that PAR 2 QO consistently outperforms existing methods across various benchmarks and workloads, achieving up to 1.96&#215; speedup over PostgreSQL and 1.83&#215; over Kepler on JOB. It avoids severe regressions, incurs acceptable training cost, and supports fast inference times. Moreover, PAR 2 QO maintains robust performance under shifting data and query distributions.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2">PRELIMINARIES AND BACKGROUND 2.1 Problem Statements</head><p>Prerequisites. Our solution is designed to work on existing database systems without changing their plan space, execution engine, or optimization procedure. We only assume that the system supports (or can be easily extended to support) the following calls. First, given a query &#119876;, &#710;&#65025; Sel(&#119876;) returns a vector of selectivity estimates for subqueries of &#119876;. Second, Opt(&#119876;, s) returns the optimal execution plan for query &#119876; given the selectivity vector s. Third, Cost(&#120587;, s) returns the estimated cost of execution plan &#120587; given the vector s of relevant selectivities. Typically, the cost of optimization is dominated by Opt; individual &#710;&#65025; Sel and Cost calls are far cheaper in comparison <ref type="bibr">[17]</ref>. For our PostgreSQL-based implementation, we use EXPLAIN to obtain estimates of costs and relevant selectivities, the same mechanism in earlier work <ref type="bibr">[21,</ref><ref type="bibr">46]</ref> for selectivity injection, and pg_hint_plan [34] for specifying the plan.</p><p>Parametric Query Optimization (PQO). A query template &#915; has a set params(&#915;) of query parameters drawn from various domains. A query (instance) &#119876; following &#915;, denoted by &#119876; &#8764; &#915;, assigns a specific set params(&#119876;) of values to the set of parameters in params(&#915;).</p><p>To avoid repeating expensive Opt calls for workloads with many instances of the same query template, PQO precomputes and/or maintains information for &#915; that enables it to efficiently find, for a given query &#119876; &#8764; &#915;, an execution plan whose cost is not much higher than that of Opt(&#119876;, &#710;&#65025; Sel(&#119876;)), without making an Opt call. Typically, PQO uses a per-template plan cache, which contains a set of candidate plans for the template, and selects the best plan from them for each incoming query at runtime.</p><p>Robust Query Optimization (RQO). In reality, when optimizing a query &#119876;, the system does not have the true selectivities s, but instead their estimates s &#710;. To quantify the penalty of making a wrong selection and to define a "robust" plan formally, we adopt the following general framework of PARQO <ref type="bibr">[46]</ref> based on stochastic optimization, which is flexible enough to encode many notions of robustness found in previous work and applications <ref type="bibr">[1,</ref><ref type="bibr">4,</ref><ref type="bibr">44]</ref>.</p><p>We assume a user-defined penalty function Penalty(&#120587;, s) specifying the penalty incurred by executing a potentially non-optimal plan &#120587; under the true selectivities s. We use the same default as PARQO, but note that our approach works for any choice of Penalty:</p><p>Here, Cost &#9733; (s) = Cost(Opt(&#119876;, s), s) is the (surrogate) optimal cost, approximated by the estimated cost of the best plan obtained by the optimizer assuming the knowledge of the true selectivities s; Cost(&#120587;, s) is the estimated cost of &#120587; when executing under s. Equation (1) defines penalty to be proportional to the amount of cost exceeding the optimal, but only if it is beyond the prescribed tolerance (&#120591; = 0.2 following the convention <ref type="bibr">[1,</ref><ref type="bibr">10,</ref><ref type="bibr">13,</ref><ref type="bibr">44,</ref><ref type="bibr">46]</ref>).</p><p>Since selectivities are uncertain, we model them as a random vector S. Assuming that S &#8764; &#119891; (s|s &#710;), the probability density function for the distribution of true selectivities s conditioned on the estimates s &#710;, we can then define the most robust plan for &#119876; as the one that minimizes the expected penalty E[Penalty(&#120587;, S) | &#710;&#65025; Sel(&#119876;)].</p><p>Parametric Robust Query Optimization. The problem is defined as follows. Given a query template &#915;, a (training) database instance D, and a (training) query workload &#119882; of queries following &#915;:</p><p>&#8226; (Cache preparation) Compute a data structure from D and &#119882; .</p><p>&#8226; (Runtime plan selection) Given a query &#119876; &#8764; &#915;, use the cached data structure to find a robust plan for &#119876;.</p><p>We first present two baseline solutions in Section 2.2 and then discuss our main solution in Section 3.</p><p>Parametric Query Workload Generation. In a "cold-start" variant of the above setup, the training query workload &#119882; is not given. This variant requires addressing the following problem: given a query template &#915; and a database instance D, generate query workload &#119882; following &#915;. Informally, we would like the generated workload to serve as a good workload for training and/or testing a parametric robust query optimizer. To this end, the generated queries should provide good coverage of the various selectivity scenarios that the optimizer can potentially encounter, including situations when the data distribution may change and the query distribution may be different. We present our solution in Section 4.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.2">Baselines: PARQO and PARQO &#8242;</head><p>PARQO <ref type="bibr">[46]</ref>, a state-of-the-art robust query optimization framework, proposes caching one robust plan per template and reusing it opportunistically at runtime. This approach serves as a rather weak baseline for PQO; hence, we additionally propose a stronger baseline called PARQO &#8242; , which elevates it into a full-fledged solution for parametric robust query optimization. We first briefly review the components of PARQO below and then describe PARQO &#8242; .</p><p>Error Profiling. PARQO uses the database instance D and the query workload &#119882; to learn an error model E for query template &#915; that allows us to construct the conditional distribution of true selectivities &#119891; (s|s &#710;) given the estimated selectivities s &#710;= &#710;&#65025; Sel(&#119876;) for a query &#119876; &#8764; &#915;. In general, optimizing a complex query may involve many selectivities, from single-table selections to multi-table selection-join subqueries; it would be infeasible to acquire all possible selectivities and represent the full joint distribution of all their errors. Therefore, PARQO chooses to model E using a collection of error profiles, each capturing a querylet, i.e., a small subquery template (up to a three-table selection-join) in &#915;. We collect these profiles by comparing the optimizer estimates with the real subqueries cardinalities observed by executing &#119882; over D. Each error profile contributes a factor to the joint distribution &#119891; (s|s &#710;).</p><p>Finding a Robust Plan. Given a plan &#119876; &#8764; &#915; and s &#710;= &#710;&#65025; Sel(&#119876;), PARQO computes a robust plan for &#119876; per Equation (1) as follows. First, to tame the complexity of subsequent optimization, PARQO identifies a small number of sensitive dimensions among those of s &#710;whose uncertainty impacts the penalty the most. This dimensionality reduction is guided by a careful sensitivity analysis that assesses each dimension's contribution to the overall variance in penalty, using Monte-Carlo sampling from &#119891; (s|s &#710;). Second, PARQO draws a number of selectivity samples from &#119891; (s|s &#710;) restricted to the sensitive dimensions, and invokes Opt with sampled selectivities to obtain a set of candidate plans. Finally, PARQO returns the candidate plan with the least expected penalty, estimated by recosting the plan at sampled selectivities and comparing its costs with the respective optimal plans at these locations.</p><p>Parametric Robust Query Optimization with PARQO. The method above is designed to find a robust plan for a single query instance. Since the overhead of finding a robust plan is high, PARQO caches a robust plan per query template. Let &#119876; c denote the query that the cached robust plan was optimized for, and let s &#710;c denote the estimated selectivities for &#119876; c . At runtime, given a new query &#119876; with the same template and estimated selectivities s &#710;, PARQO tests if the Kullback-Leibler (KL) divergence of &#119891; (s|s &#710;) from &#119891; (s|s &#710;c) is below a prescribed threshold &#120579; KL . If yes, &#119876; and &#119876; c will be almost indistinguishable from the perspective of a cardinality-based optimizer, so PARQO simply returns the cached plan for &#119876;. Otherwise, PARQO falls back to calling Opt(&#119876;, s &#710;) to obtain a plan for &#119876;, with no guarantee of robustness.</p><p>PARQO &#8242; : A Stronger Baseline. We extend PARQO to obtain a strong baseline for PQO as follows. To prepare the cache:</p><p>&#8226; Learn an error model E from D and &#119882; .</p><p>which consists of a set of candidate robust plans (&#120587; &#119894; ) along with the respective selectivities (s &#119894; ) they were obtained under. Starting with an empty C, we iterate through each query &#119876; &#8712; &#119882; with estimated selectivities s &#710;. We calculate the KL divergence of &#119891; (s|s &#710;) from &#119891; (s|s &#119894; ) for each candidate &#10216;&#120587; &#119894; , s &#119894; &#10217; &#8712; C. If the divergence is below &#120579; KL for at least one existing candidate, meaning that &#119876; is already "covered" by C, we move on. Otherwise, we find a robust plan &#120587; for &#119876; and add &#10216;&#120587;, s &#710;&#10217; to C. At runtime, given a query &#119876;, we find the candidate &#10216;&#120587; &#119894; , s &#119894; &#10217; &#8712; C that minimizes the KL divergence of &#119891; (s| &#710;&#65025; Sel(&#119876;)) from &#119891; (s|s &#710;&#119894; ), and return &#120587; &#119894; as a robust plan for &#119876;. No Opt or Cost calls are needed.</p><p>A main issue with PARQO &#8242; is that in order for a query &#119876; to reuse a cached plan &#120587; &#119894; reliably, &#119891; (s| &#710;&#65025; Sel(&#119876;)) must be very similar to &#119891; (s|s &#119894; ), so many &#10216;&#120587; &#119894; , s &#119894; &#10217; may be needed to cover the entire selectivity space. However, finding each robust plan to add to the cache is expensive, which makes the cache preparation cost high.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">PARAMETRIC PENALTY-AWARE ROBUST QUERY OPTIMIZATION</head><p>A key insight into beating the baseline in Section 2.2 is to reuse the computation involved in finding a robust plan, rather than reusing the result plans directly. We illustrate the opportunities for reusing computation with a simple conceptual example. For brevity, we will refer to &#710;&#65025; Sel(&#119876;) as the "location" of query &#119876; in the selectivity space. Intuitively, &#119891; (s| &#710;&#65025; Sel(&#119876;)) defines a "neighborhood" around (but not necessarily centered at) &#119876;, and finding a robust plan for &#119876; involves exploring this neighborhood. Suppose PARQO &#8242; has cached two plans &#120587; 1 and &#120587; 2 whose neighborhoods are both near &#119876;'s, but neither is close enough for &#119876; to justify reuse. Nonetheless, the two neighborhoods together provide sufficient coverage for &#119876;'s neighborhood. Recall that finding &#120587; 1 and &#120587; 2 in the first place required sampling plans in their neighborhoods. The same samples should be useful for finding a robust plan for &#119876;.</p><p>This insight leads us to our new solution PAR 2 QO. It changes the strategy of caching robust plans for previously seen queries of a template to caching a data structure &#120083; called the plan-penalty profiles. On a high level, &#120083; compactly represents how a set of robust plan candidates performs relative to the optimal plans (per Equation (1)) over a set of probe locations in the selectivity space. PAR 2 QO intelligently samples probe locations and uses the optimal plans to seed the set of candidate plans. This set may be too big, so for efficiency, PAR 2 QO further reduces this set to construct &#120083;. At runtime, given a query &#119876;, PAR 2 QO uses &#120083; to estimate the expected penalties of candidate plans over &#119891; (s| &#710;&#65025; Sel(&#119876;)), by reweighing per-location penalties to remove sampling bias, and selects the best.</p><p>While the high-level idea is simple, interesting challenges lie in how to design an effective sampling scheme for probe locations and how to reduce the candidate plan set in order to facilitate the identification of robust plans at runtime. In the remainder of this</p><p>Training queries (&#119882;) Error model (&#8496;) Error profiling Probe location sampling Find &amp; cost candidate plans (&#119979;) at &#8466;; perform reduction Probe locations (&#8466;) Plan-penalty profiles (&#120083;) Robust plan Offline cache preparation Runtime plan selection Query (&#119876;) &amp; est. selectivities (&amp; &#119956;) section, we describe the details of PAR 2 QO, whose workflow is depicted in Figure <ref type="figure">1</ref>. Cache preparation proceeds in three steps:</p><p>&#8226; Given D and query workload &#119882; , learn an error model E. This step is the same as the error profiling step discussed in Section 2.2. &#8226; Sample a set L of probe locations (Section 3.1).</p><p>&#8226; Find and cost candidate plans at L, and reduce/summarize the information into the plan-penalty profiles &#120083; (Section 3.2).</p><p>Selection of a robust plan at runtime is covered in Section 3.3. Finally, Section 3.4 presents an in-depth discussion of PAR 2 QO by contrasting it with other state-of-the-art approaches, highlighting the novelty of our solution and how it represents a more principled approach to achieving plan robustness, whose advantages will also be empirically demonstrated in Section 5.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.1">Sampling Probe Locations</head><p>There are two natural ideas. First, sampling should be informed by the query workload &#119882; because, intuitively, we do not want to devote much effort to regions that do not matter to queries. Second, for each query &#119876;, we want to probe not only the location &#710;&#65025; Sel(&#119876;), but also locations in the neighborhood defined by &#119891; (s| &#710;&#65025; Sel(&#119876;)), because they might yield the true optimal plan for &#119876;.</p><p>A naive approach is to randomly sample some locations in the neighborhood of each &#119876;, but there are two pitfalls. First, if the workload &#119882; is skewed, some regions of the selectivity space will be over-sampled. Such high concentrations of samples are wasteful because they have diminishing returns on improving our understanding of these regions. Second, overemphasis on popular queries diverts resources from handling less common queries that may turn out to be costly and stand to benefit more from robust plans.</p><p>Our idea is to employ a check akin to the reuse check in PARQO &#8242; (Section 2.2) to prevent over-sampling in a region: if a query "hits" a region previously sampled, we do not sample more from this region. We also track how often a region is hit by queries in &#119882; , which empirically captures the query distribution and allows us to estimate the sampling probabilities of probe locations, useful for bias correction later (Section 3.3).</p><p>The algorithm proceeds as follows. We organize the set of sampled probe locations into clusters {&#10216;L &#119894; , s &#119894; , &#8462; &#119894; &#10217;}, where L &#119894; denotes the set of probe locations in cluster &#119894;, s &#119894; serves to remember the distribution &#119891; (s|s &#119894; ) from which L &#119894; was sampled, and &#8462; &#119894; tracks how many queries in&#119882; hits this cluster. For each workload query &#119876; &#8712; &#119882; , we find the cluster &#10216;L &#119894; , s &#119894; , &#8462; &#119894; &#10217; that minimizes the KL divergence of &#119891; (s| &#710;&#65025; Sel(&#119876;)) from &#119891; (s|s &#119894; ). If this minimum divergence is below the prescribed threshold &#120579; KL , we increment &#8462; &#119894; by one and move on. Otherwise, we sample &#119899; locations from &#119891; (s| &#710;&#65025; Sel(&#119876;)), and create a new cluster {&#10216;L new , &#710;&#65025; Sel(&#119876;), 1&#10217;}, where L new contains the newly sampled locations. At the end of the process, let &#119898; &#8804; |&#119882; | denote the final number of clusters. Overall, L is the union of all L &#119894; 's, with &#119898;&#119899; locations total. The lower-right quarter of Figure <ref type="figure">2</ref> graphically illustrates our probe location sampling approach, in comparison with previous work, which is further discussed in Section 3.4.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.2">Computing Plan-Penalty Profiles</head><p>With the set L of probe locations, the next step is to invoke the query optimizer to find and cost candidate plans at L, and then post-process the resulting information into a plan-penalty profile &#120083;. Conceptually, &#120083; is a matrix whose rows correspond to candidate plans and columns correspond to the probe locations. The entry &#120083;[&#120587;, s] records the value of Penalty(&#120587;, s) defined by Equation ( <ref type="formula">1</ref>), and the row vector &#120083;[&#120587;, &#8226;] represents the penalty profile for &#120587;.</p><p>As the first step in building &#120083;, we obtain an initial set P of candidate plans and construct a plan-cost matrix C, where each row vector C[&#120587;, &#8226;] represents the cost profile of candidate plan &#120587; &#8712; P, i.e., its costs at all probe locations. To collect the set P, we call Opt(&#119876;, s) to obtain the optimal plan for each probe location s &#8712; L. Note that |P| &#8804; |L| because it is possible for the optimizer to choose the same plan for multiple locations.</p><p>Then, for each distinct candidate &#120587; &#8712; P, we call Cost(&#120587;, s) for each s &#8712; L, and store the result in entry C[&#120587;, s]. The overall running time of this step is dominated by |L| calls to Opt and |P| &#8226; |L| calls to Cost. At this point, we can simply compute &#120083; from C by calculating each entry &#120083;[&#120587;, &#8226;] using Equation (1), with Cost(&#120587;, s) = C[&#120587;, s] and Cost &#9733;</p><p>However, the size of &#120083; can be large because of the number of candidate plans. For example, in our experiments in Section 5, templates 22 and 24 from the JOB benchmark <ref type="bibr">[27]</ref> produced more than 300 candidate plans. Hence, we next focus on reducing the set P of candidate plans to a small number &#119896;. After reduction, the size of &#120083; becomes O(&#119896; |L|). Besides saving space and improving inference speed, a good plan reduction method can also help improve robustness (and hence query performance), which we will validate empirically in Section 5.</p><p>We consider two plan reduction methods below. The first method prefers choosing plans that are near-optimal at many probe locations, which heuristically reflects robustness. The second method is more conservative: it chooses a set of representative plans that can substitute for others, without second-guessing robustness at this point (later, the runtime plan selection procedure will pick, among these representatives, the best plan for the given query according to the more precise robustness criterion). We give an example comparing the results of these methods in the full version <ref type="bibr">[47]</ref>.</p><p>Reduction by &#120591;-Approximate Cover. The first method follows a natural heuristic: we prefer plans that are near-optimal at a large number of probe locations. The same heuristic and its variants have been employed by various PQO methods including QueryLog <ref type="bibr">[40]</ref> and Kepler <ref type="bibr">[15]</ref>. More precisely, we say that a plan &#120587; covers probe location</p><p>where &#120591; is the same as in Equation <ref type="bibr">(1)</ref>. Given &#119896;, the target number of candidate plans after reduction, we want to choose a subset of &#119896; plans in P that together cover as many probe locations as possible.</p><p>This problem is an instance of the set cover problem <ref type="bibr">[43]</ref>, where a simple greedy algorithm offers an approximation ratio of &#119867; (|L|) &#8804; ln |L| + 1 (in terms of the number of candidates needed to cover all probe locations). In each step, we greedily pick the candidate plan that covers the most number of probe locations that have not been covered yet. The running time is O(|P| &#8226; |L|), with no optimizer calls, and is negligible compared with the time to acquire C.</p><p>We expect this method to work well in practice, because its heuristic generally reflects robustness. However, it can miss robust plans. The reason is that this heuristic, by considering the overall number of probe locations covered, reflects a "global" measure of robustness, but at runtime, robustness in fact depends on the "local" neighborhood around the query of interest.</p><p>Reduction by Cost Profile Similarity. Our second, more conservative, method aims to choose representative plans that can generally substitute for others. To capture the extent to which two plans &#120587; and &#120587; &#8242; can substitute for each other, we want a distance metric reflecting the similarity between their cost profiles C[&#120587;, &#8226;] and</p><p>To this end, we adopt the Jensen-Shannon distance between the two discrete distributions &#119875; and &#119875; &#8242; represented by the respective profiles. More precisely, this distance is calculated as the square root of the average between the KL divergence from &#119875; to &#119872; and the KL divergence from &#119875; &#8242; to &#119872;, where &#119872; = (&#119875; + &#119875; &#8242; )/2 is a mixture distribution of &#119875; and &#119875; &#8242; . An alternative would be the Wasserstein distance, which is better at capturing shape and location differences between distributions, but we choose Jensen-Shannon because of its low computational complexity.</p><p>Then, given the target number &#119896;, we want to choose a subset of plans in P that minimizes the maximum distance between any plan in P to its closest among the &#119896; chosen. This problem is an instance of the metric &#119896;-center problem <ref type="bibr">[43]</ref>, and a range of clustering algorithms are applicable. Our implementation uses a simple greedy algorithm based on the farthest-first traversal, which gives an approximation ratio of 2. We choose the first candidate plan randomly from P and place it in our solution set &#119878;. While |S| &lt; &#119896;, we add to &#119878; the plan &#120587; in P \ &#119878; that maximizes the distance between &#120587; and plans already in &#119878;. We stop and return &#119878; once |S| = &#119896;. The running time is O(&#119896; &#8226; |P| &#8226; |L|), where the |L| factor reflects the running time of one distance computation. Again, there are no optimizer calls, so the cost is negligible compared with constructing C.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.3">Runtime Plan Selection</head><p>At runtime, PAR 2 QO has access to the error model E, the planpenalty profiles &#120083; with &#119896; candidate plans (Section 3.2), as well as additional information on the probe locations L (Section 3.1). Given a query &#119876;, PAR 2 QO uses E to derive &#119891; (s| &#710;&#65025; Sel(&#119876;)), the distribution of true selectivities conditioned on the estimates. Then, PAR 2 QO estimates the expected penalty (Section 2.1) for each of the &#119896; candidate plans, and returns the plan with the lowest estimate. To estimate E[Penalty(&#120587;, S) | &#710;&#65025; Sel(&#119876;)] for candidate plan &#120587;, we use its penalty profile &#120083;[&#120587;, &#8226;]. If the probe locations were sampled from &#119891; (s| &#710;&#65025; Sel(&#119876;)), the average penalty would yield an unbiased estimate of the expected penalty. However, since the probe locations were sampled differently, we must reweigh the penalties to correct the bias using the method of importance sampling.</p><p>The core idea is to reweigh the penalty at each probe location based on how likely that location is sampled from the target distribution &#119891; (s| &#710;&#65025; Sel(&#119876;)) and how likely that location is sampled from our sampling distribution. Recall from Section 3.1 that probe locations are organized into &#119898; clusters with &#119899; locations in each. For the &#119894;th cluster &#10216;L &#119894; , s &#119894; , &#8462; &#119894; &#10217;, its &#119899; probe locations L &#119894; = {s &#119894;,1 , s &#119894;,2 , . . . , s &#119894;,&#119899; } are sampled from &#119891; (s|s &#119894; ).</p><p>Since the &#119894;-th cluster was hit &#8462; &#119894; times by training queries, we estimate the sampling probability of this cluster as &#8462; &#119894; / &#8721;&#65025; &#119898; &#119894;=1 &#8462; &#119894; = &#8462; &#119894; /|&#119882; |, which measures how frequently Sel 1 Sel 2 Plan diagram's plans Sample uniformly in selectivity space Sel 1 Sel 2 QueryLog Sample and cost only at query points Sel 1 Sel 2 Over-concentration of samples possible Sample around each query point using fixed RCE strategy; cost only at query points Kepler Sel 1 Sel 2 Ensure just enough samples in every query region Sample and cost around query points according to error model PAR2QO Figure 2: Illustration of locations in a 2-d selectivity space where various PQO approaches obtain candidate plans (circles) and cost them (crosses), using training queries (squares) when applicable. a new query falls into cluster &#119894; based on how many times it was encountered during training. Combining both components above, we estimate the sampling probability of a specific location to be &#119904; &#119894;,&#119895; as (&#8462; &#119894; /|&#119882; |) &#8226; &#119891; (s &#119894;,&#119895; |s &#119894; ). Meanwhile, the likelihood of this location under the target distribution is &#119891; (s &#119894;,&#119895; | &#710;&#65025; Sel(&#119876;)). Hence, overall, the expected penalty of &#120587; is estimated as: 1</p><p>Since we use expected penalties to rank plans, we can simplify the above calculation into the following, by dropping terms that do not affect the ranking:</p><p>As an additional optimization, we can also cache the value of &#119891; (s &#119894;,&#119895; |s &#119894; ) when generating s &#119894;,&#119895; . Overall, the selection of the robust plan can be done by a single pass over &#120083;, so the running time is O(&#119896; |L|). No optimizer calls are needed except the single &#710;&#65025; Sel(&#119876;) call to obtain the estimated selectivities.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3.4">Discussion</head><p>We contrast PAR 2 QO with other PQO approaches, including two state-of-the-art systems, Kepler <ref type="bibr">[15]</ref> and QueryLog <ref type="bibr">[40]</ref>. Note that while previous PQO approaches do not specifically optimize for finding robust plans, many do have components whose heuristics favor keeping robust plans as candidates. We first highlight differences between PAR 2 QO and Kepler <ref type="bibr">[15]</ref>, illustrated by the lower-right and lower-left quarters of Figure <ref type="figure">2</ref>.</p><p>(1) Kepler executes plans for all training queries as well as alternative plans obtained via row-count evolution (RCE). Measuring actual execution times makes Kepler robust against errors not only in selectivity estimation but also in plan cost models. In contrast, PAR 2 QO only executes (counting versions of) training queries (and no alternative plans) to learn an error model for selectivities, and it "trusts" Cost(&#120587;, s) given correct s. Hence, PAR 2 QO spends significantly less time preparing its cache. In Section 5, we will see that focusing on selectivity errors delivers comparable or better query performance than Kepler despite a much lower initial cost. (2) Kepler explores the "neighborhood" of a training query &#119876; using RCE, which perturbs subquery selectivities in order to discover more candidate plans. This method hence improves robustness, analogous to PAR 2 QO sampling from &#119891; (s| &#710;&#65025; Sel(&#119876;)) according to the error model (Section 3.1). However, RCE uses a fixed strategy for generating perturbations (exponentially spaced in selectivity ranges), which we believe is not as effective as PAR 2 QO's perturbations informed by the error model.</p><p>(3) The same &#120591;-approximate cover method in Section 3.2 is employed by Kepler to reduce the set of candidate plans. As discussed earlier, this method helps to improve "global" robustness (over the training workload). However, unlike PAR 2 QO, which has a built-in mechanism (Section 3.1) to avoid overrepresenting popular queries, the effectiveness of Kepler's plan reduction is susceptible to an imbalanced query workload. Moreover, in determining coverage, Kepler does not consider the costs of candidate plans at locations obtained by RCE; hence, its notion of coverage is much narrower than ours. (4) Kepler makes its runtime plan selection using a neural network, combined with a method to assess prediction uncertainty. However, it is difficult to justify plan choices and interpret uncertainty. In contrast, PAR 2 QO's plan selection is transparent; the availability of the error model and the plan penalty profiles makes the selection process easy to understand.</p><p>The last point above, on PAR 2 QO's advantage of interpretability over Kepler, also applies to other black-box methods. While effective in many scenarios, these methods obscure the rationale behind plan choices, making it difficult to interpret model behavior, diagnose the root causes of regressions, and implement corrections. In contrast, PAR 2 QO's decisions can be explained by the chosen plan's cost penalty profile and the error model of selectivity estimates, as our robustness objective is clearly defined. A recent system demonstration based on PARQO <ref type="bibr">[48]</ref> shows how, given any two plans (e.g., robust vs. optimizer default), it can compare and inspect their robustness by visualizing their costs over the region of uncertainty surrounding the initial selectivity estimates. Users can see potential selectivities for which the robust plan avoids severe performance regressions. If, for any reason, robust plans frequently underperform because actual selectivity errors do not follow the error model, a clear corrective step would be to recalibrate the error model. Such ease of interpretability and diagnosis would be difficult if not impossible to achieve for black-box methods.</p><p>Next, we compare PAR 2 QO with PQO approaches that are not based on deep learning. The most recent representative is Query-Log <ref type="bibr">[40]</ref>, illustrated by the upper-right quarter of Figure <ref type="figure">2</ref>. We also touch on some earlier approaches, including plan diagrams <ref type="bibr">[13]</ref>, illustrated by the upper-left quarter of Figure <ref type="figure">2</ref>.</p><p>(1) To find candidate plans, previous work has generally used one of the following two methods. The first method, used by earlier approaches including the pioneering work of anorexic plan diagrams <ref type="bibr">[13]</ref>, attempts to cover the entire selectivity space, but quickly becomes intractable beyond 5-6 dimensions. The second method, used by QueryLog, is to sample past queries for candidate plans. However, QueryLog has no mechanism for further perturbing selectivities to obtain potentially better plans, like PAR 2 QO's sampling (Section 3.1) or Kepler's RCE. (2) To reduce the set of candidate plans, most PQO approaches, like Kepler, use the &#120591;-approximate cover method in Section 3.2 or some variants. For example, anorexic plan diagrams use the same method; QueryLog seeks a cover that minimizes an "aggregate sub-optimality" measure, which is close in spirit to this method. While this reduction naturally favors robust plans, its benefit is limited here because of how the candidates were generated in the first place: neither uniformly sampling the entire selectivity space nor focusing on the locations of the training queries alone comes close to PAR 2 QO in the ability to capture the effect of selectivity estimation errors on robustness. (3) To select among candidate plans at runtime, QueryLog employs a model using contextual multi-armed bandit learning, which can adapt dynamically over time, while earlier approaches generally perform no better than recosting all candidate plans for the query and picking the cheapest. None aims at picking a robust plan like PAR 2 QO does.</p><p>In summary, PAR 2 QO offers a systematic treatment of robustness -driven by a formal definition of robustness against errors in selectivity estimates -from initial learning of the error model, sampling of probe locations and candidate plans, construction of the plan-penalty profiles, to plan selection at runtime.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4">CARVER: WORKLOAD GENERATION GUIDED BY CARDINALITY</head><p>Training and testing query optimizers require a query workload, whose choice is not always clear. Synthetic benchmarks (e.g., DSB <ref type="bibr">[11]</ref>) typically use standard distributions (e.g., Gaussian) to generate parameter settings for given templates. Alternatively, if the database has been operating for some time, past queries can be used for the workload. In either case, there is no guarantee that such workloads reflect future queries. If our goal is robust query optimization, it is natural to make training and testing queries cover the possible scenarios that a query optimizer may potentially encounter, as comprehensively as possible. Indeed, recent work on Kepler <ref type="bibr">[15]</ref> generates parameter settings for a given query template by uniformly sampling rows from the full join result (with no selections applied), ensuring that every join result row has a chance to be covered by the generated query workload.</p><p>As argued in Section 1, however, we need a still better notion of coverage. Recall that a cost-based optimizer makes its decisions by estimating the selectivities of query predicates. Hence, it would be useful for the workload to include queries that exhibit a diverse range of selectivities. By randomly sampling final join result rows, Kepler will tend to overrepresent popular column values in its query parameters. Second, optimizer decisions are heavily influenced by the cardinalities of subqueries. Therefore, we should also generate scenarios that cover the range of possible subquery cardinalities, instead of focusing only on the final join result as Kepler does.</p><p>CARVER meets the above requirements by providing a flexible and powerful way for users to ensure that the generated queries provide good coverage of the optimization scenarios. Formally, given a database instance D and a query template &#915; with a set params(&#915;) of parameters, our goal is to generate a set of queries following the template &#915;, where each query assigns a specific value to each parameter in params(&#915;). Overall, CARVER works as follows. It randomly generates queries following template &#915; from a mixture distribution {(&#119875; &#119896; , &#119908; &#119896; )}, whose components (&#119875; &#119896; 's) and associated weights (&#119908; &#119896; 's) are specified by the user. Each component &#119875; &#119896; is specified by a set of subquery templates {&#120574; &#119896;,&#119895; } of &#915; whose parameters form a disjoint partitioning of params(&#915;). &#119875; &#119896; is defined as the product distribution &#8719;&#65025; &#119895; &#119875; &#119896;,&#119895; , where each &#119875; &#119896;,&#119895; is a distribution governing the generation of values for params(&#120574; &#119896;,&#119895; ) in the subquery template {&#120574; &#119896;,&#119895; }.</p><p>We now describe the procedure for generating from &#119875; &#119896; &#119895; for each params(&#120574; &#119896;,&#119895; ). We assume that &#120574; &#119896;,&#119895; is a selection-join query template, and that it can be rewritten as &#120590; &#120579; (&#119902;), where &#119902; is the (parameterless) base query obtained from &#120574; &#119896;,&#119895; by "removing" all atomic query predicates involving parameters, <ref type="foot">1</ref> and &#120579; is the remainder predicate involving params(&#120574; &#119896;,&#119895; ). The selectivity of a setting in params(&#120574; &#119896;,&#119895; ) is defined as |&#120590; &#120579; (&#119902;(D))|/|&#119902;(D)| where &#120579; is instantiated with the given setting. Users can specify a bucketization &#119861; of the selectivity range (not necessarily equally spaced), e.g., &#119861; = {[0, 0.5%), [0.5%, 1%), [1%, 2%), . . . , [90%, 1]}; CARVER will generate an equal number of params(&#120574; &#119896;,&#119895; ) settings for each bucket of &#119861;, up to the number of possible settings for this bucket.</p><p>Intuitively, including a subquery in the definition of mixture component guides CARVER to ensure that its generated parameters provide good coverage of the possible subquery cardinalities. Additionally, including subqueries joining multiple tables and involving multiple query parameters ensures that CARVER accounts for dependencies among join and selection predicates.</p><p>Depending on the type and complexity of the remainder predicate &#120579; , the generation procedure varies. We present several common cases below. Because of space constraints, we provide a detailed example and discuss additional challenges in the full version <ref type="bibr">[47]</ref>.</p><p>Equality Selections. Here, &#120579; has the form</p><p>where each &#119860; &#119894; is a column of some input table in &#119902;. First, we group the result rows of &#119902; by &#119860; 1 , . . . , &#119860; &#119899; and compute the row count for each group. The selectivity of &#120579; for each group (using the group-by values for parameter setting) is simply the group row count divided by |&#119902;|, the total of all group row counts. Second, we sort the groups by their counts and bucketize them according to &#119861;. Finally, we draw an equal number of samples from each bucket (unless limited by the number of groups available in the bucket). Note that the first and second steps can be computed conveniently in SQL using a SELECT-FROM-WHERE-GROUPBY-ORDERBY statement.</p><p>Note that the above procedure also handles the case of a single "not-equal-to" selection, i.e., &#120579; has the form &#119860; &#8800; &#119907;, by computing the selectivity of &#119907; as one minus its group row count divided by |&#119902;|.</p><p>Inequality Selections. Suppose that &#120579; has the form</p><p>As with the case of equality selections, we first group the result rows of &#119902; by &#119860; 1 , . . . , &#119860; &#119899; and compute the row count for each group. We then sort the groups by &#119860; 1 , . . . , &#119860; &#119899; ; the result is conceptually a &#119899;-dimensional array A representing a discrete probability density function. Let A[&#119907; 1 , . . . , &#119907; &#119899; ] denotes the array entry for (&#119907; 1 , . . . , &#119907; &#119899; ). Next, we compute the cumulative density function (CDF) over A in-place (details to be presented shortly). We then sort A by the CDF values and bucketize them according to &#119861;. Finally, we draw an equal number of samples from each bucket (again, subject to availability). All processing before the CDF computation can be done easily in SQL.</p><p>In more detail, the CDF can be computed as follows, by accumulating A over one additional dimension at a time. In the first step, for each setting of &#119860; 1 , . . . , &#119860; &#119899;-1 to &#119907; 1 , . . . , &#119907; &#119899;-1 , we update the subarray A[&#119907; 1 , . . . , &#119907; &#119899;-1 , *] to be the conditional CDF over &#119860; &#119899; by computing the prefix sum over its elements. In general, the step accumulating over &#119860; &#119894; updates each subarray A[&#119907; 1 , . . . , &#119907; &#119894; -1 , *, . . . ] to be the conditional CDF over &#119860; &#119894; , . . . , &#119860; &#119899; while setting &#119860; 1 , . . . , &#119860; &#119894; -1 to &#119907; 1 , . . . , &#119907; &#119894; -1 ; each such subarray is updated in-place as the prefix sum over its constituent subarrays updated in the previous step. The last step updates A to be the overall CDF.</p><p>The above procedure can be easily extended to support other inequality predicates: &#119860; &#119894; &lt; &#119907; &#119894; can be supported by handling the bucket boundaries slightly differently; &#119860; &#119894; &gt; &#119907; &#119894; and &#119860; &#119894; &#8805; &#119907; &#119894; can be handled by reversing &#119860; &#119894; (from ascending to descending) in the sort order of the groups. It is also possible to support range predicates in the form of &#119860; &#119894; BETWEEN &#119897; &#119894; AND &#119906; &#119894; by conceptually duplicating the column &#119860; &#119894; in input data as columns &#119860; &#119897; &#119894; and &#119860; &#119906; &#119894; , and handling the predicate as &#119860; &#119897; &#119894; &#8805; &#119897; &#119894; &#8743; &#119860; &#119906; &#119894; &#8804; &#119906; &#119894; . LIKE Selection. Suppose that &#120579; has the form &#119860; LIKE &#119907;. The design space for the generation procedure is large. We describe below the token-based approach currently employed by CARVER. Exploration of alternative approaches, such as using language models to further classify different types of LIKE-operators <ref type="bibr">[3]</ref>, is left for future work. First, we make one pass over the result rows of &#119902; to tokenize all &#119860; values. If &#119860; in general contains multi-word strings, we tokenize each &#119860; value into words. Otherwise, we tokenize each &#119860; value into characters. During the pass, we maintain the set of tokens along with the number of &#119902; result rows whose &#119860; value contains this token. Second, we sort the tokens by their counts and bucketize them according to &#119861;. Finally, the same sampling procedure is carried out over the buckets. Each token token sampled corresponds to the predicate &#119860; LIKE '%token%'.</p><p>The above procedure can be extended to a conjunction of LIKE selections. For example, to handle &#119860; 1 LIKE &#119907; 1 &#8743;&#119860; 2 LIKE &#119907; 2 , for each result row &#119902;, we will tokenize both &#119860; 1 and &#119860; 2 values and consider all pairs of tokens, one from &#119860; 1 and the other from &#119860; 2 . We maintain the set of token pairs along with the number of &#119902; result rows whose &#119860; 1 and &#119860; 2 contain the tokens in the pair, respectively.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5">EXPERIMENTS</head><p>Databases and benchmarks. Here, we focus on experiments using JOB (Join Order Benchmark) <ref type="bibr">[29]</ref>, based on real-world IMDB data, consisting of 33 query templates. It is designed to challenge optimizers with skewed/correlated data distributions and intricate join relationships. We have also performed evaluation using DSB <ref type="bibr">[11]</ref>, a recently introduced industrial benchmark built on synthetic data, extending TPC-DS <ref type="bibr">[35]</ref> with more sophisticated data distributions and correlations. Due to space constraints, however, its results are discussed only in the full version <ref type="bibr">[47]</ref>.</p><p>Workload synthesis. For JOB, we generate three different workloads: CARVER, Uniform, and Historical. For CARVER, we consider the one-component scenario by default, regarding all 2-table querylets as the set of subquery templates {&#120574; &#119896;,&#119895; } in our generator, and the selectivity bucketing for each params(&#120574; &#119896;,&#119895; ) is performed by partitioning the GROUP BY results into ten equally spaced selectivity ranges, i.e., &#119861; = {[0, 10%), [10%, 20%), . . . , [90%, 1]}. For Uniform, we first perform a full join across all tables based on the join conditions specified in the query templates. We then sample params(&#915;) uniformly from the join result, same as the synthetic method in Kepler <ref type="bibr">[15]</ref>. For Historical, we follow the methodology in PARQO <ref type="bibr">[46]</ref>; additional workload details are available in the full version <ref type="bibr">[47]</ref>. For all workload generation methods, after initial synthesis, we further ensure only queries that return nonempty results are included. We synthesize 250 queries for each params(&#915;): 50 queries are used to initialize and train PQO models; the remaining 200 queries serve as the testing workload for evaluation.</p><p>PAR 2 QO setup. We implement PAR 2 QO on top of PostgreSQL V16.2, leveraging plan and selectivity injection tools from prior work <ref type="bibr">[21,</ref><ref type="bibr">34,</ref><ref type="bibr">46]</ref>. For each &#915;, we learn the error model &#119891; (s|s &#710;) using relevant querylets containing up to 3-table subqueries, following the same procedure in PARQO <ref type="bibr">[46]</ref>. Unless otherwise specified, we set &#119899; = 50 as the number of probe locations per cluster and &#120579; KL = ln(200) as the prescribed KL divergence threshold. The sample size is user-configurable, and we demonstrate that even with this relatively small number of probe locations, PAR 2 QO achieves strong performance. The target upper bound on the number of candidate plans after reduction is max(0.2 &#8226; |P|, 10), where 10 ensures sufficient diversity when the initial |P| is small. For plan reduction, we use &#120591;-approximate cover (&#120591;-Cover in short) by default. Section 5.3 further examines the impact of these choices.</p><p>The remainder of this section is structured as follows: First, we compare PAR 2 QO's query performance against others in Section 5.1. Next, Section 5.2 compares their overhead (training and inference). Section 5.3 evaluates the contributions of components and parameter settings in PAR 2 QO through a series of ablation studies. Then, Section 5.4 assesses plan robustness under data distribution shifts. Finally, Section 5.5 evaluates how CARVER outperforms other synthetic workloads in training optimizers.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.1">Comparison of Query Performance</head><p>We compare PAR 2 QO with the following methods:</p><p>&#8226; PostgreSQL: Here, we simply rely on PostgreSQL's default behavior, invoking its optimizer separately for each query instance. While this method serves as a useful comparison point, our goal goes beyond matching the optimizer's performance -we aim to enhance plan robustness and reduce optimization time in a parametric setting. To provide a more comprehensive evaluation, Section 5.3 further introduces stronger baselines. &#8226; Kepler: Kepler <ref type="bibr">[15]</ref> is a state-of-the-art PQO method that learns from real query executions to predict the fastest plan. We use RCE to obtain candidate plans, prune candidates using its default greedy algorithm with a near-latency-optimal threshold of 1.2&#215;, and train a model for each template. &#8226; PARQO and PARQO &#8242; : PARQO refers to the one-robust-planper-template approach previously proposed for PARQO <ref type="bibr">[46]</ref>, while PARQO &#8242; is the extension introduced in Section 2.2 that considers caching multiple robust plans obtained from training queries. Both methods use the same error profiles and expectedpenalty-based metric for robust plan selection as PAR 2 QO. &#8226; QueryLog &#8242; : Following the plan population method <ref type="bibr">[40]</ref>, this baseline obtains its initial candidate set from optimal plans observed in the training workload, and then applies &#120591;-Cover plan reduction. At runtime, it selects the plan with the lowest recost, Cost(&#120587;, &#710;&#65025; Sel(&#119876;)). &#8226; Bao: Bao <ref type="bibr">[33]</ref> is a learned query optimizer that leverages reinforcement learning to generate hints for input queries. It serves as a baseline representing general-purpose learned optimizers that are not specifically tailored for the PQO setting.</p><p>For a fair comparison, all methods use the same set of training queries. Configuration of Bao is more involved; we followed the guidelines in its tutorial <ref type="bibr">[32]</ref> to obtain a reasonable setting. All configuration details are available in the full version <ref type="bibr">[47]</ref>. To reduce execution noise and simulate a warm-cache environment, we execute each selected plan 5 times and report the median latency as the final result. All experiments were conducted on a Linux server with 16 Intel(R) Core(TM) i9-11900 @ 2.50GHz processors.</p><p>Table <ref type="table">1</ref> (ignore the Other Variants section for now) summarizes the results on JOB. PAR 2 QO outperforms other methods in terms of average execution latency and delivers the highest improvement on CARVER, achieving a 1.96&#215; speedup over PostgreSQL. Recall that CARVER is a "harder" workload than Uniform and Historical, because it seeks to cover the full range of possible selectivities (Section 4). Kepler shows strong speedups on Uniform and Historical, but it achieves only a 1.07&#215; speedup on CARVER. On Historical, both Kepler and PAR 2 QO reach approximately a speedup of 1.95&#215; over PostgreSQL, higher than other baselines. PARQO &#8242; , PARQO, and Bao all achieve speedups, with PARQO &#8242; outperforming the other two, but it still underperforms PAR 2 QO. Meanwhile, QueryLog &#8242; shows slight regressions below PostgreSQL across all workloads, with the largest observed on CARVER at -1.10&#215;.</p><p>Beyond average latency, our results show that PAR 2 QO achieves a superior balance between efficiency and robustness. To quantify, Table <ref type="table">1</ref> shows the number of templates exhibiting either significant speedup/regression or severe regression, defined as follows:</p><p>&#8226; Significant speedup/regression: A change in query latency exceeding 1.2&#215;/-1.2&#215; compared with the PostgreSQL baseline. &#8226; Severe regression: A performance degradation worse than -2&#215;.</p><p>Significant speedup highlights a method's ability to find more efficient plans; however, equally critical is the ability to avoid significant/severe regressions. While Kepler achieves the largest number of significant speedups (even outperforming PAR 2 QO in this regard), it is fragile -it frequently encounters severe regressions that significantly degrade its overall average latency. In contrast, PAR 2 QO avoids such extreme cases and maintains stable performance. On the other hand, while other baselines also rarely exhibit severe regressions, they are too conservative -most achieve much fewer significant speedups compared with PAR 2 QO (with the exception of PARQO &#8242; , which gets closer to PAR 2 QO but still underperforms). Bao fares very well in avoiding both significant and severe regressions, partly because it relies on hinting rather than direct plan injection, allowing PostgreSQL to moderate its behavior; however, it also achieves far fewer significant speedups.</p><p>Table <ref type="table">1</ref>: Average execution latency (ms) and counts of significant speedup (&#8593;) / regression (&#8595;) cases, by different PQO methods and their variants, across three workloads of JOB. Latencies within 5% of the best in respective columns are highlighted.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>CARVER</head><p>Uniform Historical</p><p>PostgreSQL 536 ms ---410 ms ---637 ms ---PAR 2 QO 273 (1.96&#215;) 15 3 0 254 (1.61&#215;) 14 2 0 326 (1.95&#215;) 15 7 0 Kepler 499 (1.07&#215;) 19 5 4 306 (1.34&#215;) 15 5 2 328 (1.94&#215;) 19 2 1 PARQO &#8242; 305 (1.76&#215;) 14 7 0 305 (1.34&#215;) 13 5 0 348 (1.83&#215;) 16 4 0 PARQO 350 (1.53&#215;) 9 2 0 383 (1.07&#215;) 3 2 0 433 (1.47&#215;) 9 5 0 QueryLog &#8242; 587 (-1.10&#215;) 4 6 0 428 (-1.04&#215;) 5 4 1 668 (-1.05&#215;) 2 7 0 Bao 443 (1.21&#215;) 5 1 0 325 (1.26&#215;) 6 1 0 613 (1.04&#215;) 8 2 1 Other Variants: Uni-BestCost 658 (-1.23&#215;) 3 10 3 426 (-1.04&#215;) 4 9 5 725 (-1.14&#215;) 3 9 3 BestCost 344 (1.56&#215;) 12 3 0 355 (1.15&#215;) 12 3 0 400 (1.59&#215;) 12 1 0 BestCost-bound 513 (1.04&#215;) 10 2 0 362 (1.13&#215;) 11 3 0 591 (1.08&#215;) 9 1 0 Nearest 401 (1.34&#215;) 13 9 2 422 (-1.03&#215;) 9 6 1 377 (1.69&#215;) 15 6 1 PAR 2 QO-sim 287 (1.87&#215;) 14 4 0 270 (1.52&#215;) 14 1 0 330 (1.93&#215;) 17 5 0 PAR 2 QO-no-reduce 285 (1.88&#215;) 14 4 0 255(1.61&#215;) 14 2 0 339 (1.88&#215;) 13 8 1 BestCost-sim 420 (1.28&#215;) 11 9 1 402 (1.02&#215;) 9 2 1 446 (1.43&#215;) 8 3 0 BestCost-no-reduce 366 (1.46&#215;) 8 3 0 390 (1.05&#215;) 9 3 0 444 (1.43&#215;) 7 4 0</p><p>To further analyze the performance at template-level, we focus on PAR 2 QO and Kepler, presenting detailed execution latency and speedup results in Figure <ref type="figure">3</ref>. For clarity and simplicity, each template is labeled with the workload's initial letter plus its ID (e.g., &#119862;2 represents template 2 in CARVER, and &#119867; 1 is template 1 in Historical). We exclude templates in Figure <ref type="figure">3</ref> where neither PAR 2 QO nor Kepler exhibits significant speedup or regression. Results show that, overall, Kepler can achieve markedly higher speedups in certain scenarios. For instance, on &#119862;7 and &#119862;19, it attains 5.17&#215; and 4.03&#215; speedups, respectively, whereas PAR 2 QO only reaches 1.96&#215; and 1.10&#215;. Moreover, there are templates where Kepler provides a speedup but PAR 2 QO does not, such as &#119867; 4, &#119867; 8, &#119867; 19, &#119880; 22, and &#119880; 26. However, Figure <ref type="figure">3</ref> also highlights that PAR 2 QO effectively mitigates severe regressions: the worst performance degradation for PAR 2 QO occurs in &#119867; 4 (-1.81&#215;), while Kepler's largest regression, observed in &#119862;10, exceeds -5&#215;. These findings indicate that Kepler, by learning from real executions, can sometimes identify faster plans. However, these plans lack robustness and may fail to deliver consistent performance in practice. In contrast, PAR 2 QO effectively mitigates extreme performance degradations, leading to better overall execution latency.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.2">Comparison of Overhead</head><p>Besides the execution latencies of query plans, other types of overhead -notably the one-time (or periodic) per-workload model preparation cost and the runtime per-query optimization cost -are also important practical considerations. After all, PQO was initially motivated by the desire to reduce the per-query optimization cost, which increases the query latencies observed by users. This subsection examines the overhead of various methods in comparison with PostgreSQL. Additional details are available in the full version <ref type="bibr">[47]</ref>.</p><p>Model preparation time. By model preparation time, we mean the period from receiving the training workload to completing the model setup and being ready to generate plans for new queries. For PAR 2 QO, the first step is profiling errors using the training workload, which takes less than 13 minutes on average per query template. Then, preparing the plan-cost matrix takes about 8.5 minutes per template on average (with the default setting of &#119899; = 50,</p><p>10 1 10 2 10 3 Latency (ms) PAR&#178;QO Kepler Postgres C1 C2 C3 C4 C6 C7 C8 C9 C10C11C12C13C14C15C16C17C18C19C20C21C23C24C26C27C28C30C31C32 -3X = 5X Speedup (+/-) 18.1X -5.0X 23.7X Baseline (a) CARVER Workload  which results in |L| = 300 and |P| = 88). Subsequent plan reduction is very fast, completing under 500ms per template. Thus, the total preparation time for PAR 2 QO averages 21.5 minutes per JOB template. In contrast, Kepler requires a large number of query executions for training, where every query incurs many executions. Overall, Kepler's preparation time is over 6.5 hours per JOB template -more than 18&#215; slower than PAR 2 QO. As a comparison point, PARQO &#8242; , without PAR 2 QO's smart method of sharing computation, suffers from the high cost of finding the robust plan for each anchor independently; it takes an average of 2.4 hours per JOB template, 6.7&#215; slower than PAR 2 QO. Both Bao and QueryLog incur lower model preparation overhead, but it comes at the cost of reduced performance.</p><p>Inference time and model size. As a baseline, PostgreSQL's optimizers adds on average 67ms optimization overhead per JOB query. In comparison, Kepler is the fastest, under 1ms per query, thanks to its model directly outputting the query plan; PAR 2 QO's runtime overhead is 26ms, still considerably faster than PostgreSQL; Bao is the slowest, with 376ms per query, because it does not have the benefit of PQO. While PAR 2 QO's inference time is longer than Kepler because it still needs to carry out robustness-based plan selection at runtime, this overhead is a good trade-off in order to secure more robust and generally more efficient plans than Kepler, as shown in Section 5.1. As another comparison point, QueryLog &#8242; , despite its much simpler objective requiring no robustness evaluation, has a higher overhead <ref type="bibr">(35.4ms</ref>) than PAR 2 QO, because merely recosting plan candidates adds considerable cost. This observation further demonstrates the effectiveness of computation caching in PAR 2 QO. Finally, all methods have practically acceptable model sizes: PAR 2 QO has a 0.2MB error model plus a 1.8MB cache (2.6MB before plan reduction), totaling no more than 2.1MB at runtime; Kepler and Bao's models use very compact neural networks, which take less than 1MB space at runtime.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.3">Ablation Study of PAR 2 QO</head><p>To gain deeper insights, we design a series of experiments to evaluate the impact of various components and parameter settings in PAR 2 QO. Because of space constraints, we discuss only a subset of the results below and show an even smaller subset in Table <ref type="table">1</ref>, under the Other Variants section. Other results can be found in <ref type="bibr">[47]</ref>.</p><p>Impact of sample locations. First, we examine how PQO performance is affected by the locations from which we obtain candidate plans. To this end, we create a new variant called Uni-BestCost, which probes for its candidate plans using the same number of locations as PAR 2 QO, and similarly uses &#120591;-Cover to reduce this set. However, instead of PAR 2 QO's workload-and error-aware sampling-by-cluster strategy, Uni-BestCost samples locations uniformly at random within a hyperrectangle bounding all selectivities observed during training. Finally, when selecting plans at runtime, instead of optimizing for penalty-based robustness like PAR 2 QO, Uni-BestCost picks the candidate plan whose cost is the lowest given the estimated selectivities, just like QueryLog &#8242; . To isolate the effect of candidate plans for comparison, we create a second variant called BestCost, which is identical to Uni-BestCost except that it uses the same reduced set of candidate plans as PAR 2 QO.</p><p>Results for Uni-BestCost in Table <ref type="table">1</ref> show that using more uniform samples from the observed selectivity range is not effective -not only does it perform far worse than PAR 2 QO, but it also underperforms QueryLog &#8242; despite examining more locations. On the other hand, BestCost performs significantly better and reverses Uni-BestCost's slowdown: for CARVER, the -1.23&#215; slowdown improves to a 1.56&#215; speedup, surpassing Kepler's 1.07&#215;; for Uniform and Historical, while BestCost remains behind Kepler, it now achieves speedups over the PostgreSQL baseline. The dramatic improvement from Uni-BestCost to BestCost highlights the effectiveness of PAR 2 QO's sampling strategy in Section 3.1.</p><p>Impact of # of probe locations per cluster. We further examine the impact of &#119899;, the number of probe locations per sampling cluster, which influences |L|, the total number of sample locations. A larger &#119899; can improve plan quality, but also increases training and inference costs. When increasing &#119899; from 50 to 200, we observe improvements in some specific templates -for instance, &#119867; 4, which showed the largest regression in Figure <ref type="figure">3</ref>, improves from a -1.90&#215; regression to a 1.41&#215; speedup. However, the overall performance across workloads remains largely unchanged, indicating that a larger &#119899; provides diminishing returns in most cases. Since &#119899; influences |L| directly and |P| indirectly, it can, in the worst case, blow up overhead quadratically. In practice, increases in overhead are milder but still significant: 3.3&#215; training time and 2.1&#215; inference time compared with &#119899; = 50. On the other hand, when decreasing &#119899; from 50 to 10, we observe a clear degradation in plan quality, but even in this case, PAR 2 QO (&#119899; = 10) is still better than Kepler for CARVER and comparable for Uniform and Historical, and consistently beats PostgreSQL, Bao, and PARQO. Further details are available in <ref type="bibr">[47]</ref>. Overall, we find the setting of &#119899; = 50 to be a good default, although smarter sampling strategies that increases &#119899; adaptively on a per-template basis might be a fruitful future direction.</p><p>Impact of runtime plan selection criteria. Next, we study the impact of plan selection criteria on PQO performance. Note that the BestCost variant considered above differs from PAR 2 QO only in how it selects a plan at runtime. Since BestCost significantly underperforms PAR 2 QO as shown in Table <ref type="table">1</ref>, we can conclude that PAR 2 QO's penalty-based robustness objective is far superior to simply picking the plan with the lowest cost at estimated selectivities s &#710;. Here, for further comparison, we create two additional variants that consider alternative plan selection criteria used in previous work. First, BestCost-bound extends BestCost by incorporating a safety check, similar to the "cost check" in SRC <ref type="bibr">[17]</ref>: it checks whether the cost of a candidate plan &#120587; at s &#710;remains within a bound (1 + &#120582;) of the cost of &#120587; at the location where &#120587; was optimized (we set &#120582; = 2, as suggested by SRC <ref type="bibr">[17]</ref>); if not, the system falls back to invoking the optimizer. Second, Nearest picks the candidate plan whose location in the selectivity space is closest to s &#710;in &#8467; 2 distance, following the idea of "selectivity check" in SRC <ref type="bibr">[17]</ref>.</p><p>From Table <ref type="table">1</ref>, we observe that applying the (1 + &#120582;) safety check degrades BestCost's performance, indicating that the fallback mechanism does not guarantee a plan with truly optimal execution performance. The root cause is that the estimated selectivities s &#710;for the given query may be wrong to begin with; using s &#710;for the safety check and falling back to the optimal plan at s &#710;may not be safe in reality. From Table <ref type="table">1</ref>, we also see that Nearest fares no better than BestCost and remains far behind PAR 2 QO. To conclude, with proper accounting for uncertainty in s &#710;in its plan selection strategy, PAR 2 QO has a clear performance advantage over approaches that ignore uncertainty and/or are heuristic in nature.</p><p>Impact of plan reduction. By default, PAR 2 QO employs &#120591;-Cover for plan reduction. Recall that PAR 2 QO sets the upper bound on the number of plans (after reduction) to be max(0.2 &#8226; |P|, 10). For JOB, the average number of candidate plans obtained per template via sampling, |P|, is 88. We found that, on average, 9 candidate plans per template were sufficient to &#120591;-cover all candidates, justifying our choice of the default upper bound. In the end, PAR 2 QO kept on average 8 candidate plans per template. A smarter, template-specific selection of this upper bound and a theoretical justification of what is needed for complete coverage are interesting future directions.</p><p>To evaluate other options, we create two variants: PAR 2 QOsim, which reduces the candidate plan set by cost profile similarity (Section 3.3), and PAR 2 QO-no-reduce, which does not reduce the set at all. Results, shown in Table <ref type="table">1</ref>, indicate that both PAR 2 QO-sim and PAR 2 QO-no-reduce offer comparable performance as PAR 2 QO overall. In other words, effective plan reduction, which reduces runtime overhead, does not sacrifice plan performance. In fact, despite plan reduction, PAR 2 QO is able to slightly but consistently outperform PAR 2 QO-no-reduce, indicating that &#120591;-Cover may also help improve robustness -a point that we examine further below. A closer look at the resulting plans under both reduction methods is provided in the full version <ref type="bibr">[47]</ref>.</p><p>We also extend this ablation study to BestCost, which employs &#120591;-Cover for plan reduction but does not consider robustness explicitly when picking plans at runtime. We call the corresponding variants BestCost-sim and BestCost-no-reduce. Interestingly, from Table <ref type="table">1</ref>, we see that BestCost, with &#120591;-Cover plan reduction, noticeably outperforms BestCost-no-reduce, with no reduction. This improvement, more significant than that of PAR 2 QO over PAR 2 QOno-reduce, confirms the benefit of &#120591;-Cover in improving robustness, especially in the setting of BestCost where runtime plan selection is not robustness-based. In contrast, BestCost-sim does not offer such a benefit because its reduction method favors preserving plan diversity over robustness.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.4">Robustness Against Data Shifts</head><p>Previous experiments were conducted on a static database state. However, true robustness requires plans to maintain good performance even when data and their distributions evolve. In this experiment, we simulate real-world scenarios with shifting data distributions, which can introduce unforeseen variations in selectivity errors and plan performance.</p><p>We create multiple database instances from the original IMDB dataset using three "slicing" methods to get varying degrees of data distribution shifts. First, category-slicing <ref type="bibr">[46]</ref> splits data by item categories (kind_type.kind), which produces the most dramatic distribution shifts. 2 Second, time-slicing <ref type="bibr">[46]</ref> applies a 20% sliding window on production_year, generating 9 instances. Adjacent instances share overlapping data, while distant ones exhibit larger differences, producing smooth transitions and gradual shifts. Third, random-slicing randomly samples 20% of title along with associated data from other tables; it largely maintains the overall data distribution, representing the least challenging scenario.</p><p>For each dataset-slicing method, we synthesize three workloads (CARVER, Uniform, and Historical) by the same procedures in Section 5.1. PAR 2 QO and Kepler select plans based on one instance alone (called the "base" instance), which are then evaluated on the remaining instances. Note that PAR 2 QO's error model E is also 2 Table sizes can vary up to 51&#215; (e.g. title in "Movie" vs. "Video game"), and template execution times may fluctuate up to 176&#215; (e.g. C17 on "Movie" vs. "Video game"). The detailed selection criteria are described in the full version <ref type="bibr">[47]</ref>, along with additional experimental results. In summary, we find PAR 2 QO plans to be more robust than Kepler's across different data drift scenarios. For example, even under the most challenging category-slicing, the largest regression experienced by PAR 2 QO on non-base instances is no more than -2&#215;. Interestingly, while we do not expect to beat PostgreSQL's plans (which have access to correct statistics on these instances), PAR 2 QO in fact performs better than PostgreSQL in quite a few cases, demonstrating that robust plans can offer protection against selectivity errors regardless of their causes. In contrast, Kepler suffers severe regression in some cases, with slowdowns of up to -6&#215; compared to the baseline.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.5">Unforeseen Query Workloads and Effectiveness of CARVER for Training</head><p>We design the following experiment to see how different learned methods perform when presented with unforeseen query workloads, and to evaluate how effective CARVER is as a training workload (in comparison with Uniform and Historical). First, we train each method exclusively on each one of these workloads; then, we test the method on a mixed workload, which samples queries with equal probability from all three workloads. This mixed testing workload simulates a setting where the testing queries are drawn from a distribution from the training one, which commonly arise in practice. We want to evaluate how PAR 2 QO, Kepler, and Bao perform this setting, and determine which training workload generally leads to models with best performance. The results are shown in Table <ref type="table">2</ref>. First, we see that PAR 2 QO adapts to the unforeseen testing workload much better than Kepler and Bao, regardless of the training workload used. PAR 2 QO still outperforms the PostgreSQL baseline significantly: 1.75&#215; when trained with CARVER and &#8805; 1.35&#215; otherwise. On the other hand, Kepler and Bao experience overall slowdown, with far more templates experiencing significant regression. When trained using Historical, Kepler's -1.65&#215; slowdown -a stark reversal of its 1.94&#215; speedup in Table <ref type="table">1</ref> -can be explained by the fact that Historical queries have less diverse parameter values, which makes it harder for Kepler's model to generalize. We also provide detailed template-level performance in Figure <ref type="figure">4</ref>. <ref type="foot">3</ref> Similar to Figure <ref type="figure">3</ref>, while Kepler achieves strong performance on some templates (e.g., &#119862;19 and &#119862;30), it also suffers severe degradation in others (e.g., &#119867; 3-4, &#119867; 23, and &#119862;31). In contrast, PAR 2 QO again avoids such extreme regressions effectively, even over this unforeseen query workload. Second, training using CARVER generally gives better performance than training using Uniform or Historical, regardless of the learned method tested. For PAR 2 QO and Bao, the advantages are clear (&gt;25% and &gt;11%, respectively). For Kepler, while CARVER's advantage over Historical is clear, its advantage over Uniform is more subtle but still evident from the fewer number of significant/severe regressions. Overall, these experiments confirm the superiority of CARVER over others for training learned optimizers.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6">RELATED WORK</head><p>Parametric Query Optimization. PQO has been extensively studied over the years <ref type="bibr">[23,</ref><ref type="bibr">24]</ref>. The primary focus of traditional PQO methods is minimizing the optimizer's invocation through plan caching and reuse strategies, ensuring the plan's cost remains acceptable while avoiding unnecessary re-optimization <ref type="bibr">[2,</ref><ref type="bibr">7,</ref><ref type="bibr">17]</ref>. Different approaches have been explored to address this challenge, including caching only one plan with the lowest expected cost for the entire selectivity space <ref type="bibr">[1,</ref><ref type="bibr">7,</ref><ref type="bibr">8]</ref>, caching a set of plans <ref type="bibr">[17,</ref><ref type="bibr">20,</ref><ref type="bibr">25]</ref>, or progressively caching multiple plans over time <ref type="bibr">[2,</ref><ref type="bibr">6,</ref><ref type="bibr">26]</ref>. Some works propose to build density maps through query clustering to better capture selectivity variations <ref type="bibr">[2,</ref><ref type="bibr">20]</ref>, or building a "plan diagram" as a color-code visualization <ref type="bibr">[13,</ref><ref type="bibr">37]</ref> to provide a structured view of the selectivity space and how different plans dominate various regions. For a more comprehensive review of traditional PQO techniques, we direct readers to <ref type="bibr">[12]</ref>. Recent work, SCR <ref type="bibr">[17]</ref> applies an online selectivity and cost check to evaluate if a cached plan can be reused guaranteeing the bound on cost suboptimality, and if a new plan needs to be added into the cache. Most recent efforts, including QueryLog <ref type="bibr">[40]</ref> and Kepler <ref type="bibr">[15]</ref>, extend PQO by incorporating execution performance optimization and learning from query executions. QueryLog formalizes PQO problem as a two-step decision process, generating candidate plans and selecting the most suitable one. Kepler and PAR 2 QO adhere to this structure.</p><p>Since Kepler and QueryLog have been thoroughly discussed and compared with PAR 2 QO in Section 3.4, we omit further details here.</p><p>Robust query optimization. Traditional query optimizers often select plans that perform poorly in practice, with cardinality estimation errors being a primary cause of such degradations <ref type="bibr">[27,</ref><ref type="bibr">28]</ref>. RQO aims to select robust plans that remain stable despite inaccuracies in cardinality estimates <ref type="bibr">[31,</ref><ref type="bibr">49]</ref>. To quantify these uncertainties and guide robust plan selection, prior research assumes cardinality as a probability density function <ref type="bibr">[4,</ref><ref type="bibr">9]</ref>, a uniform distribution over the entire space <ref type="bibr">[1]</ref>, or within a bounding box <ref type="bibr">[5,</ref><ref type="bibr">19]</ref>. More recent work has developed advanced plan selection techniques: Some approaches consider worst-case sub-optimality <ref type="bibr">[16,</ref><ref type="bibr">36,</ref><ref type="bibr">41]</ref>, define robustness metrics based on cost slope and integral <ref type="bibr">[44]</ref>, or compute optimality or near-optimality ranges as robustness indicators <ref type="bibr">[14,</ref><ref type="bibr">45]</ref>. More recent work selects plans based on learned execution time distribution <ref type="bibr">[30]</ref>, and prioritizes plans using expected penalty <ref type="bibr">[46]</ref>. Another line of research explores adaptive processing, where runtime observations guide dynamic plan switching to avoid poor plan executions <ref type="bibr">[16,</ref><ref type="bibr">18,</ref><ref type="bibr">39,</ref><ref type="bibr">42,</ref><ref type="bibr">44]</ref>. For a comprehensive overview of techniques in robust query processing, we refer readers to this survey <ref type="bibr">[22]</ref>. Previous work <ref type="bibr">[10, 13-15, 37, 38, 40, 45]</ref> implicitly considers robustness when pruning plans, while PAR 2 QO takes a step further by directly integrating plan robustness into PQO.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="7">CONCLUSION AND FUTURE WORK</head><p>Selecting a PQO method in practice involves a trade-off. Kepler can sometimes find the fastest plans with low inference latency but requires expensive model training and is prone to severe regressions. QueryLog is easy to set up but may fail to improve execution performance beyond the optimizer. By integrating penalty-aware robustness into PQO, PAR 2 QO achieves a better balance between efficiency, stability, and practicality. Future work includes further expanding the search space of robust plans; sharing computation across templates; and adapting the error model/cache dynamically for evolving database states and workloads.</p></div><note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="1" xml:id="foot_0"><p>The general procedure needs to handle subtleties that arise because of OR and NOT, which we omit here.</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="3" xml:id="foot_1"><p>Templates 14, 20, and 29 are excluded in Figure</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" xml:id="foot_2"><p>4, as both PAR 2 QO and Kepler's results show no significant speedup/regression beyond 1.2&#215;.</p></note>
		</body>
		</text>
</TEI>
