<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Run-time Optimization for Pipelined Systems</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Riham Abdel Kader</string-name>
          <email>r.abdelkader@utwente.nl</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Maurice van Keulen</string-name>
          <email>m.vankeulen@utwente.nl</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Peter Boncz</string-name>
          <email>P.Boncz@cwi.nl</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Stefan Manegold</string-name>
          <email>Stefan.Manegold@cwi.nl</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>CWI</institution>
          ,
          <addr-line>Amsterdam</addr-line>
          ,
          <country country="NL">The Netherlands</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>University of Twente</institution>
          ,
          <addr-line>Enschede</addr-line>
          ,
          <country country="NL">The Netherlands</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Traditional optimizers fail to pick good execution plans, when faced with increasingly complex queries and large data sets. This failure is even more acute in the context of XQuery, due to the structured nature of the XML language. To overcome the vulnerabilities of traditional optimizers, we have previously proposed ROX, a Run-time Optimizer for XQueries, which interleaves optimization and execution of full tables. ROX has proved to be robust, even in the presence of strong correlations, but it has one limitation: it uses full materialization of intermediate results making it unsuitable for pipelined systems. Therefore, this paper proposes ROX-sampled, a variant of ROX, which executes small data samples, thus generating smaller intermediates. We conduct extensive experiments which proved that ROX-sampled is comparable to ROX in performance, and that it is still robust against correlations. The main bene t of ROX-sampled is that it allows the large number of pipelined databases to import the ROX idea into their optimization paradigm.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        The main role of a database optimizer is to explore the search space of execution
plans and pick a good one in a small amount of time. For this, the traditional
optimization paradigm relies on cardinality estimation techniques and cost models
which should accurately estimate the size and the cost of operators. But these
estimations are not always accurate. This is caused by, among others, missing
or not up-to-date statistics [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ], inability to capture data correlations [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], and
assumptions that do not re ect real-life situations [
        <xref ref-type="bibr" rid="ref10 ref5">5, 10</xref>
        ] (e.g. attribute value
independence). The innacuracy in cardinality and cost estimation propagates
exponentially through the plan, possibly causing serious optimization errors [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ].
      </p>
      <p>With XQuery, the above problems are more acute. Due to the expressiveness
and structured nature of XML, it is hard to build good cost models and concise
synopses which accurately re ect both the structure and values in documents.</p>
      <p>
        To overcome the shortcomings of traditional optimizers, we have previously
proposed ROX, a Run-time Optimizer for XQueries [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ]. ROX focuses on
optimizing the execution order of the path steps and relational joins in an XQuery.
It does so by interleaving optimization and execution steps, using sampling
techniques to estimate cardinalities of operators. Each optimization phase initiates
a sampling-based search to identify the sequence of operators most e cient to
execute rst. The execution step executes the chosen sequence of operators and
materializes the result. This allows the subsequent optimization phase to analyze
the newly materialized results to update the previously estimated cardinalities.
Note that ROX also optimizes the execution direction of steps, that is, it
decides if a step should be executed as a forward or a backward axis. By deferring
optimization to run-time, ROX is able to acquire accurate knowledge about
document characteristics and to detect existing correlations, without any need
for statistics or a cost model. The experimental results presented in [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ] have
proved that ROX is robust in nding good execution plans, even in the presence
of strong correlations, while keeping its run-time overhead limited.
      </p>
      <p>It is the alternation of optimization and execution steps followed by the full
materialization of results that gives ROX its robustness. But this also makes
ROX unsuitable for the pipelined execution style adopted by most database
systems. This paper proposes ROX-sampled, a new variant of ROX, that removes
this limitation. In a pipelined system, an operator is executed in an iterative
fashion, \piping" its output directly into the next operator. This means that
only small chunks of data is processed and saved in memory at each iteration.
In ROX-sampled, optimization and execution phases process only data samples
resulting in less materialized data, making ROX suitable to pipelined systems.</p>
      <p>Our proposed ROX-sampled approach raises some questions. Does the use of
only small samples during the optimization and execution steps jeopardize its
robustness? Will the small generated intermediates be representative enough to
detect data correlations? As will become clear later in this paper, ROX-sampled
needs, in some situations, to perform redundant operations. Will this reduce the
e ciency of ROX-sampled? The paper addresses these questions and presents
experiments that investigate the performance and e ciency of ROX-sampled.</p>
      <p>The contribution of this paper is the generalization of ROX to other pipelined
execution styles, allowing the large number of pipelined databases to import the
ROX idea into their optimization paradigm. The paper starts with
preliminaries (Section 2) followed by a brief description of the original ROX, referred to
hereafter as ROX-full (Section 3). Then ROX-sampled is explained, including
the requirements that a pipelined system should support to e ciently run ROX
(Section 4). Finally the conducted experiments are presented (Section 5).
2</p>
    </sec>
    <sec id="sec-2">
      <title>Preliminaries</title>
      <p>We now describe the foundations on which ROX builds: the join graph, the used
physical algorithms and indexes, and the sampling techniques.
2.1</p>
      <sec id="sec-2-1">
        <title>Join Graphs</title>
        <p>
          ROX takes as input a join graph, which represents the to-be-ordered path steps
and relational joins in XQuery, without any implications on their execution order.
An input XQuery is rst completely compiled into a DAG-shaped plan [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ], which
author
//
/
author
author
        </p>
        <p>author
//
/
//
/
text() = text() = text() = text()</p>
        <p>
          =
root root root root
conf1.xml conf2.xml conf3.xml conf4.xml
=
//
/
for $a1 in doc("conf1.xml")//author,
$a2 in doc("conf2.xml")//author,
$a3 in doc("conf3.xml")//author,
$a4 in doc("conf4.xml")//author,
where $a1/text() = $a2/text() and
$a1/text() = $a3/text() and
$a1/text() = $a4/text()
return $a1
=
Fig. 1. Join graph of the 4-way join XQuery returning authors that have published in
4 di erent conferences.
is then statically optimized in such a way that XPath steps, joins, selections, and
projections are grouped together forming a join graph [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ]. An XQuery and its
join graph are shown in Fig. 1. A vertex in a join graph represents a relation
of XML elements, text, or attribute nodes, which is input and output to steps
and joins. An edge speci es an XPath step or join relationships between two
vertices. A step is depicted as |ax where the label ax de nes the axis of the step
and the circle \ " denotes the context set of the step. Note that this is only
a representational issue; ROX may decide to execute the edge in the reverse
direction. The edge |= depicts a relational join. The dotted edges in Fig. 1
represent join equivalences, and are added by ROX to broaden the search space,
allowing more exibility to nd a good plan. The join graph extraction might fail
to group all steps and joins in one cluster resulting in a plan containing several
join graphs. ROX will then optimize each graph separately. In this paper, we
only consider plans with a single join graph.
2.2
        </p>
      </sec>
      <sec id="sec-2-2">
        <title>Operators and Index Structures</title>
        <p>
          ROX is implemented on top of MonetDB/XQuery where XML documents are
shredded into relational tables using a pre/post numbering scheme [
          <xref ref-type="bibr" rid="ref2">2</xref>
          ]. In
addition to the standard relational operators, MonetDB/XQuery provides the
Staircase join, a structural join capable of exploiting the tree properties of the
pre/post plane to execute a single XPath step with linear complexity and at most
a single sequential traversal over the XML document [
          <xref ref-type="bibr" rid="ref8">8</xref>
          ]. Additionally, MonetDB
implements element- and value-indexes, which can fetch XML nodes with a
certain quali ed name, and text and attribute nodes satisfying a given predicate
value. It is also possible, given a set of values, to probe the value indexes to
evaluate equi-joins. In MonetDB, indexes are automatically built when loading
the documents in the database. The complexity of an index lookup, as well as
the cost of nding the count of qualifying tuples, is logarithmic to the index size.
2.3
        </p>
      </sec>
      <sec id="sec-2-3">
        <title>Sample-based Operations</title>
        <p>ROX uses sampling techniques to estimate the cardinality of vertices and edges
in the join graph. To limit the time spent on sampling, only physical
operators satisfying the zero-investment property should be sampled. These operators
do not require any investment (e.g. sorting) prior to starting execution, and
therefore their cost is linearly dependent on the size of the outer operand. All
operators used in the ROX algorithm satisfy the zero-investment property.</p>
        <p>
          To estimate the cardinality of a vertex in the join graph, the appropriate
index is sampled. To estimate the size of an edge, the corresponding operator is
sampled using an index based join sampling technique [
          <xref ref-type="bibr" rid="ref14">14</xref>
          ] which takes a sample
of input tuples from the outer operand, and looks-up (e ciently, using an
index) all matching tuples in the inner operand. The output size of the sampling
operation is then extrapolated to estimate the cardinality of the operator. This
technique can be used for sampling staircase joins, and equality joins using the
value indexes. Although the edge is executed with a sample, it can be an
expensive operation if the join hit ratio is high. To avoid situations where large results
are generated (the cartesian product in the worst case), the sampled execution
of a given operator is stopped when the size of the generated output reaches
a cuto limit . Consequently, sampling needs to keep track of the number of
tuples n of the sampled input S that contributed to its output r, to linearly
extrapolate the size of the full sampling result R as jRj = jSj
jnj jrj.
        </p>
        <p>De nitions - Given an edge e = (v; v0), we de ne the following:
{ The weight of e is an estimation of the size of the operator associated to e.
{ edges (v; v0) is the set of all edges contained in the paths of executed edges
branching from v, excluding the path starting with the edge (v; v0).
We give an example of the second de nition using the join graph in Fig. 1. We
refer to the edges (author(1); text()(1)), (text()(1); text()(2)), (text()(2); text()(3)),
and (text()(1); text()(4)) with respectively e1, e2, e3, e4. The superscript (i)
denotes the document conf i:xml. If we suppose that the above 4 edges have already
been executed, then edges (text()(1); author(1)) is equal to fe2, e3, e4g.
3</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>ROX-full: a Brief Description</title>
      <p>
        This section brie y describes ROX-full, a complete presentation is given in [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ].
The ROX-full algorithm consists of an initialization phase (Phase 1) followed by
a phase where optimization and execution steps are alternated (Phase 2).
Phase 1: This phase initializes the join graph by picking the rst samples, and
estimating the cardinality of its vertices and edges. For a given vertex v, built
indexes are sampled to estimate the number of tuples corresponding to v, and
to retrieve a sample of these tuples. The weight of an edge e is computed by
rst sampling the edge e, and then linearly extrapolating the estimated output
size. The input to the sampling operation is chosen from the vertex of e that
has the smallest cardinality. In fact, picking the input sample from the smaller
table provides a more representative set of the data, leading to a more accurate
estimation of the weight of e.
      </p>
      <p>Phase 2: This phase is the core of the ROX algorithm where optimization and
execution steps are iterated. During optimization, a search for a superior path in
the join graph is initiated. The search begins from the edge e with the smallest
weight. Although e is the most selective edge, ROX does not proceed with
executing it immediately. Instead chain sampling is used to search for a potential
sequence of operators that is more selective than e. This can be compared to
hill-climbing: ROX invests a small amount of time exploring the surrounding of
e to avoid the execution of a local minimum. Note that if the vertices of edge e
do not have branching unexecuted edges, no chain sampling will take place and
the edge will be directly executed.</p>
      <p>Chain sampling consists of exploring in a breadth rst manner the paths of
unexecuted edges branching from e, sampling iteratively one edge in each path.
By consecutively sampling edges in one path, using the output of one sampling
operation as input to the next, it is possible to detect correlations between the
joined vertices. The input to the sampling operation of the rst edge in each
path is picked from the vertex v of e that has the smallest cardinality. At the
end of each sampling iteration, a stopping condition searches for a path that is
highly selective compared to the others. If such a path exists, chain sampling
is stopped and the path is returned for execution. Otherwise and when all the
edges in the paths branching from e are sampled, another condition checks for
the most selective path and returns it for execution.</p>
      <p>The execution phase evaluates the edges in the chosen path, using full tables
as input, and materializes the result. Consequently the data in the vertices of
the join graph are updated, and the weights of edges are recomputed using the
newly materialized data. Optimization and execution steps are alternated until
all edges in the join graph are executed.</p>
      <p>ROX-full, the rst XQuery optimizer that interleaves optimization and
execution, proved to be a robust optimizer that improves the state-of-art in XQuery
optimization. It does not depend on statistics nor a cost model, and chooses good
execution plans even in the presence of strong data correlations while keeping its
run-time overhead limited. ROX can handle a large class of the XQuery language
by optimizing the join graph as part of a bigger execution plan. Although
proposed in the XQuery context and implemented on top of MonetDB/XQuery, the
ROX idea can be generalized to other systems and query languages, especially
SPARQL in which a large number of self-joins are expressed.
4</p>
    </sec>
    <sec id="sec-4">
      <title>ROX-sampled</title>
      <p>We now introduce ROX-sampled, a variant of ROX, which makes the ROX idea
also suitable for pipelined systems. ROX-full is not suitable for pipelined systems
because its execution steps process operators with full tables, hence generating
large intermediates. Therefore, the execution phases in ROX-sampled does not
manipulate full tables. In fact, ROX-sampled follows the same steps as
ROXfull, with main di erence that only data samples are used throughout the whole
algorithm. Therefore unlike ROX-full, where the optimization phase works with</p>
      <sec id="sec-4-1">
        <title>Join</title>
      </sec>
      <sec id="sec-4-2">
        <title>Graph</title>
      </sec>
      <sec id="sec-4-3">
        <title>Join</title>
      </sec>
      <sec id="sec-4-4">
        <title>Graph</title>
      </sec>
      <sec id="sec-4-5">
        <title>Optimization</title>
        <p>phase using
sample data</p>
      </sec>
      <sec id="sec-4-6">
        <title>Optimization</title>
        <p>phase using
sample data</p>
      </sec>
      <sec id="sec-4-7">
        <title>Execution</title>
        <p>phase using
full data
ROX-sampled</p>
      </sec>
      <sec id="sec-4-8">
        <title>Execution</title>
        <p>phase using
full-sample
data</p>
      </sec>
      <sec id="sec-4-9">
        <title>Results</title>
      </sec>
      <sec id="sec-4-10">
        <title>Final</title>
        <p>plan execution
using
full data</p>
      </sec>
      <sec id="sec-4-11">
        <title>Results</title>
        <p>a data sample while the execution phase processes full tables, both the
optimization and execution phases of ROX-sampled manipulate data samples (Fig. 2).
This means that the execution phases of ROX-sampled consist of sampling edges
instead of executing them with full tables. Note that we use the term executing
e to refer to the process of sampling e during an execution phase. Although both
optimization and execution phases of ROX-sampled consist of sampling
operations, each phase might use a di erent cuto limit in their sampling; execution
steps might specify a larger cuto to allow for more results to be generated.</p>
        <p>In ROX-full, two types of relations are associated to a vertex v: the full
table F T (v) which contains the XML nodes corresponding to v and which is
used as input and output to execution operations, and a sample table S(v)
chosen randomly from F T (v) and used in the sampling operations. In
ROXsampled, three relations are associated to a vertex v: the full table F T (v) which
contains the XML nodes corresponding to v, a full-sample table F S(v) whose
content is initially a random sample of tuples picked from F T (v) and afterwards
is input and output to execution operations, and a sample table S(v) chosen
randomly from F S(v) and used in the sampling operations. Full-samples in
ROXsampled have the same role full tables have in ROX-full; however, they are
of a much smaller size. The content of full tables in ROX-sampled is never
changed, while, after each execution step, the content of full-sample tables is
updated to the result of the processed steps and joins. Each decision made by
an optimization phase is executed with the full-sample tables, and saved as part
of a nal execution plan. When ROX-sampled terminates, the saved plan is
executed using the full tables. By limiting the amount of data accessed from
base tables, processed and materialized at every execution phase, it becomes
possible to apply ROX to pipelined systems.
An issue arises when executing or sampling an edge e with two executed vertices
e = (v1; v2). A vertex v is an executed vertex if at least one of its edges is
executed. The problem is that a join between two sample sets from v1 and v2
does not result in a random sample of the output of the join between v1 and v2.
(a) Join graph before the execution
of edge e = (v1; v2).</p>
        <p>(b) The join graph illustrating the
execution of the edge e = (v1; v2).
More precisely, S(R1) ./ S(R2) 6= S(R1 ./ R2). We stress that our goal is both
to estimate the size of a join or step and to create a representative sample of the
operator's output, which results in reliable cardinalities and outputs when used
in further evaluations. Next, a solution to the problem is presented for the case
of executing e. The same solution will be used for the sampling case.</p>
        <p>Again, the problem is that F S(v1) ./ F S(v2) does not result in a good sample
of the join between v1 and v2. The solution we propose is not to use the
fullsample of one of the vertices, but instead use the full table, i.e. F S(v1) ./ F T (v2).
This operation will match the tuples in F S(v1) with all XML nodes in the
document corresponding to v2. However, F S(v2) contains the result of all joins
and steps that were already executed between v2 and other vertices. Therefore,
to correctly re ect those previous executions, the output of the join between
F S(v1) and F T (v2) should be used as input to re-evaluate all the executed edges
branching from v2. The solution is illustrated in the join graph of Fig. 3(a) where
solid and dashed lines represent respectively executed and non executed edges.
First edge e is executed using as input F S(v1) and F T (v2), then the result is
input to the join with F T (q1), and so on until all edges in edges (v2; v1) are
reexecuted. The execution order is depicted in Fig. 3(b) as labels on edges while
the arrows indicate the execution direction (i.e. the vertex from which the
fullsample data is used as input for the execution). The decision to execute F S(v1) ./
F T (v2) instead of F S(v2) ./ F T (v1) aims at reducing the number of redundant
evaluations, and stems from the fact that jedges (v2; v1)j &lt; jedges (v1; v2)j.</p>
        <p>For the sampling case of e, the same procedure is applied, but instead of using
F S(v1) as input it uses S(v1). The goal of sampling e during an optimization
phase is to also estimate its cardinality. Therefore, the proposed solution keeps
track of the join hit ratio of all the sampled operators, to derive an estimation
of the size of e. We omit the details due to lack of space.
4.2</p>
        <sec id="sec-4-11-1">
          <title>Running ROX-sampled in Other Systems</title>
          <p>Now that we have explained ROX-sampled and the MonetDB operators and
data structures it uses, we brie y discuss the requirements to run ROX-sampled
in other systems. We will focus on two points: picking the initial samples for
each vertex, and the sampling of joins.</p>
          <p>
            To pick the initial samples of XML nodes, ROX-sampled uses index lookups.
Another method is to have the samples pre-built and saved in the database. This
is comparable to collecting statistics, but instead of storing the data
characteristics about each attribute, a representative sample of the attribute's values is
saved. A good survey about sampling techniques is [
            <xref ref-type="bibr" rid="ref6">6</xref>
            ].
          </p>
          <p>
            The sampling of edges is performed using an index-based join between a
sample and a full table. This requires the existence of an index on one of the
joined attributes. Techniques that e ciently sample a join without the use of an
index have been proposed in [
            <xref ref-type="bibr" rid="ref4">4</xref>
            ]; however, they require the existence of statistics,
a requirement we do not want ROX to depend on. Therefore if an index on the
joined attribute is not available, a hash-based join can be used. But this means
that hash tables must be built on both the input sample and the entire relation.
The rst is quite cheap. Hashing the entire relation is expensive, but can be a
cheap operation if it is used when the join is executed with the full data; however
this is not guaranteed to happen as it depends on the generated plan. Note that
the hash table will be used in subsequent sampling operations which amortizes
the cost of building it. We defer a study of the impact of using hash-based joins
on the performance of ROX to later work.
5
          </p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>Experiments</title>
      <p>
        A prototype of ROX is implemented on top of the \Jun2008" release of
MonetDB/XQuery1. Path nder, the XQuery processor of MonetDB [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], generates
the isolated join graph for a given XQuery and provides it as input to ROX. For
all experiments presented here, we use a PC equipped with two 2 GHz dual-core
AMD Opteron 270 processors, 8 GB RAM, running 64-bit Fedora 8.
      </p>
      <p>The experiments use the DBLP XML dataset2, and the 4-way join XQuery
template shown in Fig. 1. The DBLP document is split up into 4500 single
XML documents, one for each journal and conference. By replacing the 4
documents in the XQuery by 4 journal and/or conferences chosen from the same
or di erent research areas, ROX-sampled will be tested against queries with
different degrees of correlation. It is in general more likely that authors publish in
various journals and/or conferences of one research area, than that an author
publishes in multiple research areas. We cluster the document combinations,
according to their anticipated correlation, into 3 groups: group 2:2, group 3:1,
group 4:0. A group x:y contains all combinations of 4 documents such that x
number of documents are chosen from the same research area and y number of
documents are picked from a di erent area. Since it is not possible to use all
4500 documents in our experiments, we select 23 \representative" documents
from 5 research areas (Database, Data mining, Information retrieval,
Bioinformatics, Arti cial Intelligence), which results in 831 document combinations. The
size of the documents extracted from the original DBLP document ranges from
300 B to 4.8 MB. ROX + MonetDB/XQuery evaluate these queries in less than
50 milliseconds. To achieve more reliable performance measurements, we scale
the complete dataset to 45 GB by replicating each article 100 times.
1 http://monetdb.cwi.nl/XQuery/
2 http://dblp.uni-trier.de/xml/</p>
      <p>all equi_joins</p>
      <p>Operators similarly ordered
(a) Plan comparison.</p>
      <p>ryque llapan1.6</p>
      <p>Execution order of operators: Our rst experiment runs ROX-full and
ROXsampled on the 831 document combinations using 3 di erent sample sizes =
f100; 500; 1000g, and compares the chosen execution order of operators. Fig. 4(a)
shows the percentage of queries optimized to the same plan by the two ROX.
With a sample size equal to 100, only 20% of the plans are similar. This
number increases to 48% when a sample size of 1000 is used. We also report the
percentage of plans in which equi-joins are ordered similarly. This is of interest
since the correlations between the 4 queried documents is detected through the
estimated size of the equi-joins. Therefore when the two variants order the
equijoins similarly, it means that they detect and handle the correlations in the same
manner. The percentage of plans with the same order of equi-joins grows from
55% to 73% when the sample size increases from 100 to 1000. We conclude that
an increase in the sample size reduces the di erences between the ROX variants.
With a sample size equal to 1000, ROX-sampled is comparable to ROX-full in
detecting correlations, and di ers mainly in ordering the step operators.
Execution time of plans: The second experiment compares the execution time
of the plans generated by the two ROX variants. Fig. 4(b) shows the average
normalized execution time relative to the fastest time. For each variant, we
time the chosen plan (pure plan), and the full-run which includes the sampling
overhead. The execution time of the pure plan of ROX-sampled decreases when
a bigger sample size is used. With a sample size of 100, the execution time of
ROX-sampled is on average 9% longer than ROX-full, and it decreases to 6%
when a sample size of 1000 is used. The execution time of the full run plans
increases when a larger sample is used. We note that ROX-sampled has a higher
sampling overhead than ROX-full. This is expected since, the time spent in the
execution steps of ROX-sampled and to re-execute and resample some edges
contributes to the optimization overhead.</p>
      <p>Fig. 5 shows the normalized execution times of the four plans. The symbols (+)
and (-) denote respectively full run plans and pure plans. We also consider the
plan that a classical compile time optimizer would generate. The optimizer is
able to accurately estimate the cardinality of operations carried on a single
document, but lacks the ability to estimate the correlations existing among several
documents. This results in an order of joins that re ects a smallest-input- rst
heuristic where the two smallest inputs are joined rst, which is then joined
with the third largest input, and so on. The pure plan of ROX-full is the fastest
almost all the time, except for very few queries. This is caused by the use of
non representative samples during chain sampling which leads to bad execution
decisions. A way to solve this is by detecting the error during execution and
restarting the optimization phase. ROX-sampled is close to ROX-full, but for
very few queries, it can be 3 times slower. The sampling overhead (full run) is
on average around 30%. This plot shows that both ROX variants are robust
and insensitive to the di erent correlations, while the classical optimizer shows
strong variations.</p>
      <p>Impact of the cuto limit: In our last experiment, we vary the cuto limit
used during the execution steps of ROX-sampled. As explained in Section 4, the
optimization and execution steps of ROX-sampled might use a di erent cuto
limit for their sampling operations. In our previous experiments, sampling during
execution steps was performed with an unlimited cuto limit: all tuples in the
sample input were consumed by the sampling operation. In this experiment, the
cuto limit is set to the double of the sample size. The cuto limit used during
the optimization steps in the current and previous experiments is equal to the
sample size. Fig. 6 shows the average normalized execution time of ROX-full,
ROX-sampled, and ROX-sampled using a cuto . We notice that the use of a
small cuto results in a small increase in the execution times of ROX-sampled,
while the use of a cuto limit of 2000 does not. Therefore, it is possible to use
an appropriate cuto limit in ROX-sampled without a ecting its performance.
ROX-sampled has also been evaluated against XMark documents3, and proved
to be successful in picking a good execution order for the operators in the join
graph. One XQuery, containing 15 XPath steps and 2 equality joins, is interesting
3 http://www.xml-benchmark.org/</p>
      <p>
        500
Sample size
1000
to mention with greater detail (the query can be found in [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ]). In this query, a
correlation exists between the 3 elements: open auction, current, bidder. Di erent
values in the predicate condition assigned to the current element result in a
higher or lower cardinality for the other 2 attributes. ROX-sampled proved to
be capable of detecting the correlation and its changing e ects, and to exploit
it in determining the execution order of the operators in the join graph.
6
      </p>
    </sec>
    <sec id="sec-6">
      <title>Related Work</title>
      <p>
        Adaptive query processing has been researched during the last few years.
Parametric query optimization [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] generates at compile-time several plans each
optimal for a partition of the parameters domain. When at run-time the value of
these parameters is known, the appropriate plan is executed. Query re-optimization [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ]
re-optimizes the plan if during execution, the observed costs di er from the
estimates made during optimization. The work in [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ] complements the above
approach by embedding in the plan validity ranges which de ne the bounds of
the estimated values for which the plan is valid. If the observed cardinalities
fall outside these bounds, the plan is re-optimized. Other techniques [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ] have
a feedback loop which adjusts the statistics and cost functions in the database
based on observation made during the plan's execution; however their learning
curve can be long. The quality of plan chosen by the above three classes of
techniques still highly depends on the accuracy of statistics and cost models. They
have a reactive behavior and can not detect early enough selective correlations
which can speed up performance. On the contrary, ROX is a proactive
optimizer which does not depend on any statistics or cost model, and can detect and
exploit correlations during optimization. We note that ROX-sampled can use
re-optimization techniques similar to [
        <xref ref-type="bibr" rid="ref11 ref13">11, 13</xref>
        ], if, during the execution of the
chosen plan with full tables, the observed cardinalities di er from the cardinalities
estimated by the sampling operations.
      </p>
      <p>
        Eddies [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], a routing based technique, do not depend on statistics or a cost
model. They route each tuple to the most e cient sequence of operators based
on observed properties. Eddies need to maintain query execution states which
can become expensive. They also require the presence of symmetric operators
which restricts the number of alternative plans they consider.
      </p>
    </sec>
    <sec id="sec-7">
      <title>Conclusion</title>
      <p>In this paper, we described ROX-sampled which generalizes the ROX idea to
pipelined systems. ROX-sampled is a proactive optimizer which does not depend
on statistics nor a cost model, and is robust in face of correlations. We also
discussed the requirement to run ROX-sampled on other systems. Extensive
experiments were conducted and showed that the performance of ROX-sampled
is close to that of ROX-full, especially with larger sample sizes.</p>
      <p>As future work, we plan to make ROX dynamic with respect to the time it
spends on optimization, i.e. able to balance between the sampling overhead and
the estimated execution time of the query. Currently, the execution decisions
in ROX are based on operators' cardinality. A future extension to ROX would
also take into account the execution time of operators. Finally, we want to study
e cient ways of integrating operators like Sorting, Distinct and Grouping into
the join graph and the optimization and evaluation environment of ROX.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>R.</given-names>
            <surname>Avnur</surname>
          </string-name>
          and
          <string-name>
            <given-names>J. M.</given-names>
            <surname>Hellerstein</surname>
          </string-name>
          . Eddies:
          <article-title>Continuously adaptive query processing</article-title>
          .
          <source>In SIGMOD</source>
          ,
          <year>2000</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>P.</given-names>
            <surname>Boncz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Grust</surname>
          </string-name>
          , M. van
          <string-name>
            <surname>Keulen</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          <string-name>
            <surname>Manegold</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          <string-name>
            <surname>Rittinger</surname>
            , and
            <given-names>J. Teubner.</given-names>
          </string-name>
          <article-title>MonetDB/XQuery: a fast XQuery processor powered by a relational engine</article-title>
          .
          <source>In SIGMOD</source>
          ,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>S.</given-names>
            <surname>Chaudhuri</surname>
          </string-name>
          .
          <article-title>Query optimizers: Time to rethink the contract</article-title>
          ? In SIGMOD,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>S.</given-names>
            <surname>Chaudhuri</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Motwani</surname>
          </string-name>
          , and
          <string-name>
            <given-names>V.</given-names>
            <surname>Narasayya</surname>
          </string-name>
          .
          <article-title>On random sampling over joins</article-title>
          .
          <source>SIGMOD Record</source>
          ,
          <year>1999</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>S.</given-names>
            <surname>Christodoulakis</surname>
          </string-name>
          .
          <article-title>Implications of certain assumptions in database performance evaluation</article-title>
          .
          <source>ACM Trans. on Database Systems</source>
          ,
          <year>1984</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>O.</given-names>
            <surname>Frank</surname>
          </string-name>
          and
          <string-name>
            <given-names>R.</given-names>
            <surname>Doron</surname>
          </string-name>
          .
          <article-title>Random sampling from databases - a survey</article-title>
          .
          <source>Statistics and Computing</source>
          ,
          <year>1994</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>G.</given-names>
            <surname>Graefe</surname>
          </string-name>
          and
          <string-name>
            <given-names>K.</given-names>
            <surname>Ward</surname>
          </string-name>
          .
          <article-title>Dynamic query evaluation plans</article-title>
          .
          <source>SIGMOD Record</source>
          ,
          <year>1989</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>T.</given-names>
            <surname>Grust</surname>
          </string-name>
          ,
          <string-name>
            <surname>M. Van Keulen</surname>
            ,
            <given-names>and J.</given-names>
          </string-name>
          <string-name>
            <surname>Teubner</surname>
          </string-name>
          .
          <article-title>Accelerating xpath evaluation in any rdbms</article-title>
          .
          <source>ACM Trans. on Database Syst</source>
          .,
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <given-names>T.</given-names>
            <surname>Grust</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Mayr</surname>
          </string-name>
          , and
          <string-name>
            <given-names>J.</given-names>
            <surname>Rittinger</surname>
          </string-name>
          .
          <article-title>Xquery join graph isolation: Celebrating 30+ years of xquery processing technology</article-title>
          .
          <source>In ICDE</source>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <given-names>Y. E.</given-names>
            <surname>Ioannidis</surname>
          </string-name>
          and
          <string-name>
            <given-names>S.</given-names>
            <surname>Christodoulakis</surname>
          </string-name>
          .
          <article-title>On the propagation of errors in the size of join results</article-title>
          .
          <source>SIGMOD Record</source>
          ,
          <year>1991</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <given-names>N.</given-names>
            <surname>Kabra</surname>
          </string-name>
          and
          <string-name>
            <given-names>D. J.</given-names>
            <surname>DeWitt</surname>
          </string-name>
          .
          <article-title>E cient mid-query re-optimization of sub-optimal query execution plans</article-title>
          .
          <source>SIGMOD Record</source>
          ,
          <year>1998</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12. R. Abdel Kader,
          <string-name>
            <given-names>P.</given-names>
            <surname>Boncz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Manegold</surname>
          </string-name>
          , and
          <string-name>
            <surname>M. van Keulen. Rox:</surname>
          </string-name>
          <article-title>Run-time optimization of XQueries</article-title>
          . In SIGMOD,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <given-names>V.</given-names>
            <surname>Markl</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Raman</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Simmen</surname>
          </string-name>
          , G. Lohman,
          <string-name>
            <given-names>H.</given-names>
            <surname>Pirahesh</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>Cilimdzic</surname>
          </string-name>
          .
          <article-title>Robust query processing through progressive optimization</article-title>
          .
          <source>In SIGMOD</source>
          ,
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <given-names>F.</given-names>
            <surname>Olken</surname>
          </string-name>
          . Random Sampling from Databases.
          <source>PhD thesis</source>
          , University of California at Berkeley,
          <year>1993</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <surname>M. Stillger</surname>
            ,
            <given-names>G. M.</given-names>
          </string-name>
          <string-name>
            <surname>Lohman</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          <string-name>
            <surname>Markl</surname>
            , and
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Kandil. LEO -</surname>
          </string-name>
          <article-title>DB2's LEarning Optimizer</article-title>
          . In VLDB,
          <year>2001</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>