Divergent Physical Design Tuning for Replicated Databases

Page created by Virginia Murphy
 
CONTINUE READING
Divergent Physical Design Tuning for
                                      Replicated Databases

        Mariano P. Consens                           Kleoni Ioannidou                      Jeff LeFevre                   Neoklis Polyzotis
           Univ. of Toronto                             UC Santa Cruz                      UC Santa Cruz                     UC Santa Cruz
       consens@cs.toronto.edu                        kleoni@cs.ucsc.edu                jlefevre@cs.ucsc.edu                alkis@cs.ucsc.edu

ABSTRACT                                                                             replicas) of the data at different nodes, and ensures that they remain
We introduce divergent designs as a novel tuning paradigm for                        synchronized when updates are applied to the database. Replication
database systems that employ replication. A divergent design in-                     may occur at different levels of granularity, from subsets of tuples
stalls a different physical configuration (e.g., indexes and materi-                 to a complete database. In all cases, the main motivation behind
alized views) with each database replica, specializing replicas for                  replication is to cope with node failures and ensure high availabil-
different subsets of the workload. At runtime, queries are routed                    ity, but quite often replication is also used to enable the parallel
to the subset of the replicas configured to yield the most efficient                 servicing of a workload in a load-balanced fashion.
execution plans. When compared to uniformly designed replicas,                          In this work, we introduce the paradigm of a divergent design,
divergent replicas can potentially execute their subset of the queries               which leverages replication for the purpose of tuning the database
significantly faster, and their physical configurations could be ini-                system more effectively. Specifically, a divergent design installs
tialized and maintained (updated) in less time. However, the spe-                    a different physical configuration (e.g., indexes and materialized
cialization of divergent replicas limits the ability to load-balance                 views) with each replica in order to specialize it for a subset of the
the workload at runtime.                                                             workload. In this fashion, a query statement in the incoming work-
   We formalize the divergent design problem, characterize the prop-                 load is routed to the replica that can evaluate it most efficiently.
erties of good designs, and analyze the complexity of identifying                    Our proposed approach is in contrast to the current state of the
the optimal divergent design. Our paradigm captures the trade-off                    practice, where each replica has the exact same physical configu-
between load balancing among all n replicas vs. load balancing                       ration (a uniform design). By allowing the configuration of each
among m ≤ n specialized replicas. We develop an effective al-                        replica to diverge, a divergent design utilizes the aggregate storage
gorithm (leveraging single-node-tuning functionality) to compute                     in the system more effectively (i.e., more indexes and materialized
good divergent designs for all the points of this trade-off. Ex-                     views are built overall) and consequently enables higher benefits
perimental results validate the effectiveness of the algorithm and                   for more queries in the workload together with faster initialization
demonstrate that divergent designs can substantially improve work-                   and maintenance of replicas.
load performance.                                                                       Several real-world systems employ replication and can thus ben-
                                                                                     efit directly from divergent designs. Database systems that run in
                                                                                     the cloud using a Database-as-a-Service provider are one example.
Categories and Subject Descriptors                                                   These providers typically employ commodity hardware to run the
H.2.2 [Database Management]: Physical Design                                         database system and rely on replication to cope with failures as
                                                                                     well as achieve scalability. Two such examples are Microsoft SQL
                                                                                     Azure [2], which employs 3-way replication, and Amazon’s Rela-
General Terms                                                                        tional Database Service [1], where up to 5 read replicas of MySQL
Performance                                                                          databases can be launched on-demand to provide scalability. These
                                                                                     systems fully replicate the database on several nodes, thus allowing
Keywords                                                                             a query to be evaluated on any replica. In both cases, a divergent
                                                                                     design will allow replicas to specialize for subsets of the workload
physical design tuning, divergence, replicated databases                             and thus improve performance of query processing. A similar case
                                                                                     can also be made for parallel database systems which employ repli-
1.     INTRODUCTION                                                                  cation for high availability, failure recovery, and performance e.g.,
  Data replication is an ubiquitous feature in distributed database                  the recently announced Teradata Unity feature. In addition, diver-
systems. In a nutshell, the system maintains several copies (or                      gent designs can be particularly beneficial in the context of ad-hoc
                                                                                     data analytics. For instance, a data scientist may procure several
                                                                                     machines from a private or public cloud (e.g., Amazon EC2), spin
                                                                                     up several database instances for the same data set, and then use di-
Permission to make digital or hard copies of all or part of this work for            vergent designs to efficiently evaluate a heavy analytics workload
personal or classroom use is granted without fee provided that copies are            in parallel. In all these examples, using a divergent design does not
not made or distributed for profit or commercial advantage and that copies           require any changes to the underlying query processor. It is only
bear this notice and the full citation on the first page. To copy otherwise, to      a matter of installing a different configuration on each replica and
republish, to post on servers or to redistribute to lists, requires prior specific
permission and/or a fee.
                                                                                     taking care of routing queries to the appropriate replicas.
SIGMOD ’12, May 20–24, 2012, Scottsdale, Arizona, USA.
Copyright 2012 ACM 978-1-4503-1247-9/12/05 ...$10.00.
The focus of our work is the problem of divergent design tun-              partition of the workload and then refines it in an iterative fash-
ing, i.e., how to compute a beneficial divergent design for a system          ion. We formally show that each iteration leads to a better par-
that employs database replication. The problem involves numer-                tition and also that the generated designs have provably good
ous technical challenges. Choosing a good divergent design re-                properties.
quires reasoning about possible subsets of the workload and how
they can benefit from possible configurations, which already leads        • We present an extensive experimental study using a commercial
to a doubly-exponential space of solutions. In particular, diver-           DBMS to evaluate the potential of divergent designs and also
gent design tuning can be viewed as a generalization of physical            the effectiveness of our tuning algorithm (Section 5). The re-
design tuning for a single node, which is already known to be a             sults demonstrate that our tuning algorithm runs efficiently and
hard problem [5]. Another source of complication is the tension             yields divergent designs that have several benefits: the available
between best-case performance and load balancing. Specifically,             space budget for physical configurations is utilized more effec-
the specialization of replicas to different subsets of the workload         tively; the time to build the configuration of each replica drops
may cause a query to have really good performance on one replica            significantly as the configuration size increases; update state-
but really bad performance everywhere else. In turn, this variability       ments are executed faster; and, query performance improves
can result in load imbalance and bad overall performance, e.g., in          significantly, without compromising the ability to load-balance
the case where a query cannot be routed to its “best” replica. Our          the system.
work shows that it is non-trivial to determine a good trade-off point       We also discuss the implementation of divergent designs in an
between specialization and load balancing.                               actual DBMS (Section 6). Existing systems can already reap some
   There is a long line of studies on physical design tuning, however    benefits from divergent designs. However, to realize the full poten-
no previous work examines the concept of divergent designs that          tial of divergent design tuning, it becomes necessary to modify the
we introduce in our work. Several studies investigate the problem        policies for query routing and load balancing.
of tuning the configuration of a single system [3, 4, 10], but they do
not examine the interplay with replication. In fact, the current state
of the practice is to apply these techniques to tune the configuration   2.     DIVERGENT DESIGN TUNING: PROB-
of a single replica, and then to copy the resulting configuration on            LEM STATEMENT
every other replica. The concept of fractured mirrors [12] is similar
in spirit to divergent designs, except that it assumes exactly two       Preliminaries. We first review some basic concepts from the con-
replicas of the database that are stored in row- and column-based        ventional problem of physical design tuning over a single database.
format respectively, and also requires a modified query processor.       The problem of divergent design tuning extends these concepts to
In contrast, a divergent design installs a “richer” configuration on     a parallel environment where the database is replicated.
each replica based on the data structures (e.g., indexes, materialized      In conventional physical design tuning, we are given a represen-
views, row- and column-based storage) that are already supported         tative workload W and a space budget b, and the goal is to com-
by the query processor. (A more detailed review of related work          pute a configuration that minimizes the cost to evaluate W and fits
appears in Section 7.)                                                   within the space budget b. The computed configuration typically
Contributions. The technical contributions of our work can be            comprises materialized views and (primary or secondary) indexes
summarized as follows.                                                   over tables and views. Formally, let W = Q ∪ U where Q is the
                                                                         query workload and U is the update workload. Since W plays the
 • We formally introduce the concept of a divergent design and           role of a representative workload, it is common to provide a weight
   define the problem of divergent design tuning (Section 2). Our        function f : W →
Divergent Physical Design Tuning. We extend the previous con-               (to be detailed shortly). Second, we can leverage the existing liter-
cepts to a system where the database is replicated across n ma-             ature on automated tuning techniques, and in particular the existing
chines. We consider the cases described in Section 1, where each            advisor tools, in order to compute the configuration of each replica.
replica i ∈ [1, n] holds a full copy of the database. Moreover, we              To model the performance
assume that replicas have the same space budget b for their config-         of a divergent design p we
                                                                                                                                   pA
uration. Our techniques are readily extensible to the case where the        could extend the SingleCost                            pB
unit of replication is a partition of the database, or when replicas        metric, where each query q
may have different space budgets.                                           in W is now evaluated by
   In this particular setting, each query statement q can be evaluated      the replica with the best phys-
by any replica in the system. (Of course, the performance of query          ical design for q.                For-
evaluation may be different depending on which replica is chosen.)          mally, let I1 , . . . , In denote
On the other hand, each update statement u has to be evaluated              the replica configurations cor-                cost(q, J1q ) cost(q, J2q ) cost(q, J3q )
at each replica, in order to ensure consistency. The system may             responding to p.             We de-
use different strategies to ensure synchronization for updates, e.g.,       fine J1q , . . . , Jnq as the permu-
                                                                                                                          Figure 1: An illustration
eager vs lazy, but this choice is completely orthogonal to our tech-        tation of I1 , . . . , In such that
                                                                                         q                  q             of the trade-off between
niques.                                                                     cost(q, J1 ) ≤ cost(q, J2 ) ≤
                                                                                                   q          q           load balancing and perfor-
   The high-level idea of a divergent physical design is to allow           · · · ≤ cost(q, Jn ), i.e., Jj is
                                                                                                                          mance.
each replica to have a different physical design, tailored to a partic-     the physical design of the j-th
ular subset of the workload. Formally, let {Q1 , . . . , Qn } denote a      best replica for q. Hence, the
partition of the query workload Q to n (potentially overlapping)            best-case total evaluation cost for W can be expressed as follows:
subsets. The partition of Q induces a partition of W in corre-                                     X                           X X
sponding subsets W1 , . . . , Wn , that we call sub-partitions such that    BestCost(p) =               f (q)cost(q, J1q ) +                 f (u)cost(u, Ii )
Wi = Qi ∪ U . We use partitions(W ) to denote the set of such                                     q∈Q                            u∈U i∈[1,n]

partitions. Essentially, Wi represents the subset of the workload for       This metric reflects the total work performed by the system when
which replica i is specialized. Note that each Wi contains U , since        each query is routed to its best replica and each update is routed to
all updates have to be applied to all replicas. We couple the parti-        all replicas.
tion {W1 , . . . , Wn } with a set of corresponding weight functions           The problem with the previous metric is that it ignores com-
{f1 , . . . , fn }, where fi () sets the weights of queries and updates     pletely the issues of load-balancing and parallel processing for queries.
in Wi . (We will impose certain restrictions on fi later.) In what          Specifically, the metric does not guard against the case where cost
follows, we use p = {(W1 , f1 ), . . . , (Wn , fn )} to denote the com-     (q, J1q )
metric for conventional physical design tuning, to the case where           good divergent designs. We couple these theoretical results with
m replicas equally share the cost of each query. Returning to the           an exhaustive investigation of the space of divergent designs for
example of Figure 1, design pB outperforms pA for m = 2, but pA             a small-scale instance of the problem. Overall, the theoretical re-
is better for m = 1.                                                        sults and our empirical observations demonstrate the challenges be-
   We now formulate the problem that we tackle in this paper, namely        hind the problem: there is a vast search space of divergent designs;
computing the optimal divergent design.                                     identifying the optimal design is computationally hard; there exists
                                                                            a very big performance gap between good and bad designs; and,
   D EFINITION 2.2 (O PTIMAL D IVERGENT D ESIGN ). Given a                  there are relatively few good designs. These insights contribute di-
workload W , a weight function f , a number of replicas n and a             rectly to the design of the tuning algorithm presented in the next
load-balancing factor m ≤ n, compute the divergent design p that            section.
minimizes TotalCost(p, m).
We can also formulate an alternative problem statement, where we
                                                                            3.1    Theoretical Analysis
optimize m based on a desired trade-off between best-case perfor-             For the purpose of our theoretical analysis, we assume that
mance and load balancing.                                                   DBAdv (W, f, b) returns the optimal configuration for any W , f
                                                                            and b. This assumption allows us to analyze the properties of di-
   D EFINITION 2.3 (O PTIMAL m AND D ESIGN ). Given a work-                 vergent design tuning without having to model the imperfections
load W , a weight function f , a number of replicas n, a threshold          of the advisor. We stress that the tuning algorithm we present in
τ ∈ (0, 1] and the uniform design punif = {(W, f ), . . . , (W, f )},       Section 4 does not rely on this assumption.
compute the maximal m and corresponding divergent design p such               First, we investigate the computational complexity of identifying
that TotalCost(p, m) ≤ τ TotalCost(punif , n).                              the optimal divergent design.

In this case, we seek to find the divergent design that offers the            T HEOREM 3.1. The optimal divergent design cannot be com-
most opportunities for load balancing and improves on the baseline          puted in polynomial time unless P = N P .
uniform design at least by a factor of τ . In the extended version
of the paper, we prove that any PTIME algorithm to solve the first          The proof shows that the decision problem of divergent design tun-
problem yields a PTIME algorithm to solve the second problem,               ing is NP-Hard, through a reduction from the NP-Complete subset
by using binary search to identify the maximal value for m. Hence,          sum problem. Therefore, instead of looking for an optimal al-
from this point onward, we focus on the first problem.                      gorithm to solve the problem, our goal is to develop an efficient
   For purposes that will become clear in the next section, we dis-         algorithm that computes good divergent designs. In this direction,
tinguish the class of l-balanced divergent designs. The formal def-         we analyze further the space of possible divergent designs in order
inition follows.                                                            to build some intuition on the properties of good solutions.
                                                                               Recall that the fully-balanced design pFB installs the same con-
   D EFINITION 2.4 (l-BALANCED D ESIGN ). A divergent design                figuration in all replicas, computed based on the complete workload
p = {(W1 , f1 ), . . . , (Wn , fn )} is called l-balanced iff the follow-   W and a modified weight function fFB (q) = f (q)/n. The intuition
ing two conditions hold:                                                    behind pFB is that each query q can be evaluated by any replica with
 • Each q ∈ W appears in exactly l sub-partitions of p, i.e.,               the same cost, and hence the original weight f (q) is equally spread
    {i | i ∈ [1, n] ∧ q ∈ Wi } has exactly l elements for any               across all replicas. This intuition makes the fully-balanced design a
    q ∈ W.                                                                  natural choice for m = n, and in fact we prove that it is an optimal
                                                                            solution.
 • fi (q) = f (q)/l if q ∈ Wi and fi (q) = 0 otherwise, for any
   q ∈ W and i ∈ [1, n].                                                       T HEOREM 3.2. The fully-balanced design pFB is optimal if m =
In an l-balanced design p, each query q directly affects the con-           n, i.e., T otalCost(pFB , n) ≤ T otalCost(p, n) for any other de-
figuration of exactly l replicas. Moreover, the original weight of q        sign p.
is uniformly distributed among the l sub-partitions that contain q.
A special case of an l-balanced design is the fully-balanced design            Our next step is to consider the other extreme point of m = 1,
pFB = {(W, fFB ), . . . , (W, fFB )} where l = n, i.e., each query q        where we care for best-case performance. A 1-balanced design
appears in every sub-partition with weight fFB (q) = f (q)/n. Sim-          is a natural choice for m = 1, since it naturally associates each
ilar to the uniform design, the fully-balanced design installs the          query with a single replica. However, proving optimality is far from
same configuration IFB = DBAdv (W, fFB , b) in each replica. The            trivial, given that there are many such designs and also because
difference is that queries have their weights deflated by n, which          the best cost for q may not come from the configuration that has
intuitively reflects the fact that q can be evaluated by any of the n       considered q. Still, we are able to show an important result: the
replicas with equal cost cost(q, IFB ). The counter-part to the fully-      fully-balanced design cannot beat any 1-balanced design for m =
balanced design pFB is a 1-balanced design p, where each query              1. In fact, we prove the following generalization:
q directly affects the configuration of exactly one replica. Note
that application designs (when modeling each query as occurring               T HEOREM 3.3. TotalCost(p, m) ≤ TotalCost(pFB , m) for any
in only one application) are 1-balanced designs with the disjoint           m ∈ [1, n] and any m-balanced design p.
partition determined by the given applications.
                                                                               This result reflects the tension between load-balancing and per-
                                                                            formance. The fully-balanced design offers the greatest flexibility
3.    PROBLEM ANALYSIS                                                      for load-balancing (and is in fact optimal for m = n), since each
   Having defined the problem of divergent design tuning, our next          query q has the same cost on each replica. On the other hand, an
step is to develop some intuition about the space of possible solu-         m-balanced design tries to specialize m replicas per query, which
tions. Our approach is two-pronged. First, we present a theoretical         reduces the flexibility for load-balancing but improves the cost of
analysis on the complexity of the problem and the properties of             workload evaluation.
The previous two theorems lead us to the following intuition                            25-th Perc.    Median     75-th Perc.    Max
about the properties of a “good” divergent design p: The overlap                 m=1         ×2.54        ×4.47        ×25.1        ×26.8
between sub-partitions should increase as m increases. Indeed, the               m=2         ×2.98        ×5.07        ×5.24        ×5.42
fully-balanced design pFB , whose sub-partitions Wi overlap com-
pletely, is optimal for m = n. Conversely, for any m < n, pFB              Table 1: Distribution statistics for divergent design costs in the
cannot beat any m-balanced design where each q appears in ex-              exhaustive experiment. For designs in each cost percentile, we
actly m sub-partitions. These observations play a crucial role in          show the ratio of TotalCost to the optimal design cost.
the divergent design algorithm that we describe in the next section.
   We conclude our analysis by comparing divergent designs against         designs in order to contain the scope of the study and also due to
the current practice in real systems, which is the uniform design.         the nice theoretical properties of these designs. We handpicked the
We expect punif to be mostly relevant for m = n, and hence a               queries and tuned the available space budget to simulate the follow-
natural starting point for our analysis is to compare punif to the op-     ing realistic scenario: different subsets of queries can benefit from
timal design pFB . We prove below that we should always prefer the         similar indexes, but the indexes for different subsets are too large
fully balanced design compared to the uniform design for any value         to fit in a single configuration. This is representative of what we
of the load balancing factor.                                              expect to see in practice. Intuitively, a good divergent design will
  T HEOREM 3.4. The uniform design cannot outperform the fully             specialize a different replica for each subset.
balanced design for any load balancing factor, i.e.,                          We set n = 3 and then exhaustively enumerate all possible l-
TotalCost(punif , m) ≥ TotalCost(pFB , m) for any m ∈ [1, n]               balanced designs, for l ∈ [1, 3]. Overall, this yielded 486 distinct
                                                                           designs. For each design p, we computed the corresponding con-
   Intuitively, this result can be explained by the asymmetry be-          figurations I1 , I2 , and I3 by invoking the DB2 Design Advisor on
tween queries and updates. Recall that a query q can be evalu-             each sub-partition Wi . Finally, we used DB2’s what-if query opti-
ated by any single replica, whereas an update u has to be evaluated        mizer to compute TotalCost(p, m) for m = 1 and m = 2. (We
by all n replicas. Hence, the contribution of queries to the total         do not consider m = 3 since we already know that pFB is optimal.)
work metric decreases by a factor of n compared to the updates.               We performed the whole computation on Amazon EC2 using
The fully balanced design pFB uses fFB (q) = f (q)/n for query             ten separate IBM DB2 instances so that we could parallelize the
weights, and therefore the configuration IFB = DBAdv (W, fFB , b)          process. Overall, it required many hours of computation time in
takes directly into account this decrease in contribution. On the          order to fully explore the search space. The main overhead was
other hand, punif ignores the deflation of query importance, as it         the cost of invoking DB2’s Design Advisor (several seconds) to
uses the unmodified query weights. The resulting configuration             compute the physical design for each sub-partition Wi , even with
Iunif = DBAdv (W, f, b) is basically oblivious to the increased            our toy workload. Since an exhaustive search will be impractical
importance of updates.                                                     for real workloads with tens of queries, any reasonable divergent
   We have already seen that pFB cannot lose to punif (Theorem             design tuning algorithm should explore only a small part of the
3.4), and by Theorem 3.3, we conclude that given a fixed value for         search space.
m, the uniform design punif cannot improve on any m-balanced                  The results revealed several interesting properties for the space
design p.                                                                  of balanced designs for this particular setup. First, we observed
                                                                           that the optimal design for a fixed value of m is an m-balanced de-
   C OROLLARY 3.5. TotalCost(punif , m) ≥ TotalCost(p, m)                  sign, for m ∈ [1, 3]. Intuitively, an l-balanced design with l > m
for any m ∈ [1, n] and any m-balanced design p.                            provides more flexibility for load balancing than specified by m,
This general result provides even stronger evidence in favor of sub-       and hence misses the opportunity to tighten the specialization of
stituting punif (again, the current state of the practice) with a diver-   replicas. On the other hand, l < m leads to over-specialization
gent design. Note that any m-balanced design has the potential to          and hence to imbalances among the first m replicas for each query.
improve on punif . The reason can be traced again to the asymme-           Based on these empirical observations, we can formulate the fol-
try between queries and updates, but also to the semantics of the          lowing conjecture.
load-balancing factor m. Recall that m specifies that each query              C ONJECTURE 3.6. Let pm denote an m-balanced divergent de-
q should have m replicas on which it has a low execution cost.             sign and pl denote an l-balanced design, for l 6= m. Then, it holds
An m-balanced design p attempts to achieve this goal by placing            that minpm T otalCost(pm , m) ≤ minpl T otalCost(pl , m).
q in exactly m sub-partitions and thus having q affect the design
of m replicas. This placement still affords some specialization per           As a next step in our analysis, we examine the distribution statis-
replica, since each Wi contains a subset of the queries. In contrast,      tics of the TotalCost() metric within each class of m-balanced
punif corresponds to a single configuration Iunif that is tuned for        designs, for m = 1, 2. In each case, there are 6 designs, out
the whole workload, which means that no replica is specialized.            of the 243 designs in the class, which achieve the minimal value
Moreover, punif may over-provision in terms of load balancing,             for TotalCost(). Table 1 further shows the distribution of the
since each query has the same cost on all n ≥ m replicas. These            TotalCost() values within each class in relation to these optimal
two factors contribute to the sub-optimality of punif compared to          designs. For instance, for m = 1, the 25-th percentile (that is, the
an m-balanced design.                                                      TotalCost value that bounds 25% of the designs) is ×2.54 worse
                                                                           than the optimal cost within the class. Overall, the results show
3.2     Empirical Analysis                                                 that non-optimal designs have significantly higher cost, and hence
   The second part of our analysis is empirical, and aims to provide       a random selection is not likely to yield a good solution to the di-
further insights on the space of good divergent designs.                   vergent tuning problem.
   We conduct a small-scale empirical study of l-balanced designs             It is also interesting to examine the cost of punif with respect
with a workload of five queries from the TPC-DS benchmark [15],            to the optimal in each class. Specifically, TotalCost(punif , 1) is
using IBM DB2 as the underlying DBMS. The details of the ex-               ×26.8 higher than the optimal cost for the class of 1-balanced de-
perimental setup are given in Section 5. We focused on balanced            signs. The same ratio for m = 2 is ×5.42. Hence, the current
practice of employing a uniform design may lead to a huge loss in                       q1 q2 q3                   q1 q2 q3                 q1 q2 q3
performance compared to a divergent design.                                         W10 X X                    I10 10 20 10             W11 X
                                                                                    W20       X                I20 20 10 5              W21    X X

4.    THE D IVG D ESIGN ALGORITHM FOR DI-                                                  (a)                       (b)                        (c)
      VERGENT DESIGN TUNING
                                                                                Figure 2: An example of running the D IVG D ESIGN algorithm
   In this section, we present an efficient algorithm called D IVG D ESIGN
                                                                                for m = 1, n = 2 and a workload of three queries: (a) Initial
that computes effective divergent designs. We first provide an overview
                                                                                design, (b) Query costs under the corresponding configurations
of the key ideas behind the algorithm, and then present the detailed
                                                                                (minimum costs are indicated with bold); (c) Refined designs.
pseudocode. We conclude with a theoretical analysis that demon-
strates the nice theoretical properties of D IVG D ESIGN.
                                                                                    Function D I V G D E S I G N (W, n, m, b)
                                                                                    Input: Workload W ; number of replicas n; load-balancing factor m;
4.1     Overview of Our Approach                                                            space budget b.
    The first design choice behind D IVG D ESIGN is to output m-                    Output: A divergent design p that is m-balanced.
balanced designs, for the value of m in the problem specification.                  Knobs: Improvement threshold ; Max number of iterations IterMax
This choice is justified by the theoretical evidence for the nice prop-         1   Pick a random m-balanced design p0 = {(W10 , f10 ), . . . , (Wn0 , fn0 )}
                                                                                2   x←0
erties of such designs: the m-balanced design for m = n is opti-                3   repeat
mal; and any m-balanced design has the potential to improve on the              4       foreach i ∈ [1, n] do
baseline punif partition. The key challenge therefore is to identify            5            Iix ← DBAdv (Wix , fi , b)
an m-balanced design p such that TotalCost(p, m) is small.                      6       Initialize Wix+1 = U for all i ∈ [1, n]
    Intuitively, a good design should have the property that J1q , . . . , Jm
                                                                            q
                                                                                7       foreach q ∈ Q do
(the m best configurations for q among I1 , . . . , In ) correspond to          8            Let J1q , . . . , Jnq be a permutation of I1l , . . . , Inl such that
the configurations of the sub-partitions that contain q. Otherwise,                          cost(q, J1q ) ≤ cost(q, J2q ) · · · ≤ cost(q, Jnq )
this implies that q affects directly the computation of some configu-           9            foreach j ∈ [1, m] do add q to Wix+1 such that Iix = Jjq
ration Ii = DBAdv (Wi , fi , b) (by being part of the workload Wi ),                                     x+1     x+1               x+1     x+1
without however using Ii in the T otalCost metric. In that sense,               10     px+1 ← {(W1 , f1 ), . . . , (Wn , fn )}
                                                                                11     x←x+1
it is better to take q out of Wi , in order to allow Ii to be tuned even
                                                                                12 until |TotalCost(px−1 , m) − TotalCost(px , m)| <  or
further for the remaining statements in Wi .                                        x > IterMax
    Enforcing the aforementioned property is quite challenging, due             13 return p
to the black-box nature of function DBAdv (). Essentially, it is                                 Figure 3: Pseudocode for D IVG D ESIGN
infeasible to partition queries based on some analysis of their fea-
tures, given that we do not make any assumptions about the imple-               Figure 2(b). Note that query q2 appears in W10 and yet has the least
mentation of DBAdv (). Instead, we have to rely on a trial-and-                 execution cost with configuration I20 . This may happen because
error approach to identify a good partition p, but with a smart strat-          q2 is more “similar” to q3 in terms of beneficial configurations,
egy that avoids enumerating an exponential number of partitions.                e.g., both benefit from the same indexes or materialized views, and
    The proposed D IVG D ESIGN algorithm employs a strategy that is             hence I20 , which is computed based on q3 , is more effective for q2
inspired by the well-known k-means clustering algorithm. The lat-               compared to I10 . Based on the computed costs, the algorithm moves
ter is designed to solve clustering problems that employ a black-box            each query to the sub-partition corresponding to the least cost. The
distance function. The idea is simple and yet quite effective: start            resulting partition {W11 , W21 } is shown in Figure 2(c), where q2
with a random selection of points as the cluster medoids, assign                now appears in the same sub-partition with q3 . This new partition
the remaining points to clusters based on the closest medoid, iden-             becomes the input of the next iteration, and the iterations continue
tify the new medoid per cluster, and then iterate in the same fash-             until a convergence condition (which we discuss later) is satisfied.
ion until the clustering converges to a stable state. D IVG D ESIGN                Overall, D IVG D ESIGN tries to create partitions that group queries
works in a similar fashion. First, it computes a random partition               that are highly “similar” with respect to the configuration elements
of the workload {W10 , . . . , Wn0 } and the corresponding configu-             (e.g., indexes or materialized views) that benefit them. This strat-
rations Ii0 = DBAdv (Wi0 , fi0 , b), for i ∈ [1, n]. Subsequently,              egy ensures that each resulting configuration Ii = DBAdv (Wi , fi , b)
the algorithm computes cost(q, Ii0 ) for all q ∈ Q and i ∈ [1, n],              is beneficial for all the queries in Wi . Equally importantly, this sim-
and “moves” each query q to the sub-partitions that correspond                  ilarity is computed indirectly through the output of the black-box
to the lowest evaluation costs. This process yields a new parti-                function DBAdv (), without the need to model the logic of the con-
tion {W11 , . . . , Wn1 }, which is used to compute new configurations          figuration advisor.
I11 , . . . , In1 and another assignment of queries to sub-partitions. This
iterative process continues until there is convergence.                         4.2      Algorithm Definition
    Figure 2 illustrates an iteration of D IVG D ESIGN with a simple                Figure 3 shows the pseudocode of the D IVG D ESIGN algorithm
example. Assume that we have n = 2 replicas, m = 1 and the                      that we introduce in this paper. The algorithm receives as input the
workload contains three queries q1 , q2 , q3 and no updates. The al-            workload W , the number of replicas n, the space budget b, and the
gorithm starts with an initial random partition p = {W10 , W20 },               load balancing factor m, and outputs an m-balanced design p such
shown in Figure 2(a). We show the partition in the form of a ma-                that TotalCost(p, m) is small.
trix, where a cell (i, q) is checked if q appears in Wi0 . This par-                The algorithm picks (line 1) an initial design p0 = {(W10 , f10 ),
tition yields configurations I10 = DBAdv (W10 , f10 , b) and I20 =              . . . , (Wn0 , fn0 )} and then refines it in an iterative fashion (lines 3–
DBAdv (W20 , f20 , b), which are computed by invoking the config-               12). Keep in mind that the weight functions f10 , . . . , fn0 are fully
uration advisor on the corresponding sub-partitions. Subsequently,              specified through the sub-partitions W10 , . . . , Wn0 given that p is an
the algorithm computes the execution cost of each query under                   m-balanced design (Definition 2.4). Hence, it suffices to pick a ran-
these configurations. An example of resulting costs are shown in                dom partition {W10 , . . . , Wn0 } in order to initialize p0 . We use x as
the variable that tracks the current iteration number, and use px =                 Parameter        Values
{(W1x , f1x ), . . . , (Wnx , fnx )} for the design at the beginning of the         n                2, 3, 4
current iteration, and px+1 = {(W1x+1 , f1x+1 ), . . . , (Wnx+1 , fnx+1 )}          m                1, 2
for the design at the end of the current iteration. (As always, the                 Space budgets    0.25×, 0.5×, 1.0×, 2.0×, INF (infinite)
weight functions are determined based on the sub-partitions ac-
cording to Definition 2.4.) Each iteration comprises two steps.                        Table 2: Summary of experimental parameters.
In the first step, the algorithm computes the configuration Iix of            aborts the current iteration if this happens and restarts the algorithm
replica i by invoking the configuration advisor on Wix , i.e., Iix =          with a different random design. Our experiments (Section 5) show
DBAdv (Wix , fix , b). In the second step, the algorithm computes             that random initialization and restarts work well in practice.
the new design based on these configurations. Specifically, for
each query q ∈ Q, D IVG D ESIGN computes cost(q, Iix ) for all                5.     EXPERIMENTAL STUDY
i ∈ [1, n], and then identifies the m configurations J1q , . . . , Jm     q
       x           x
from I1 , . . . , In that yield the m least costs for q. Then, q is added        This section presents the results of an experimental study that we
to Wix+1 if Ii is among J1q , . . . , Jm  q
                                            . Hence, each query is assigned   conducted in order to evaluate the effectiveness of the D IVG D ESIGN
to the m sub-partitions that correspond to the m most efficient eval-         algorithm and the performance of the divergent designs that it com-
uation plans for the query.                                                   putes. We first discuss the methodology we followed for the exper-
   How do we know that this iterative process converges to a good             iments and then present our findings.
design? One of our key contributions is to show that each itera-              5.1     Methodology
tion of D IVG D ESIGN cannot worsen the quality of p under certain
assumptions.                                                                  Data Sets and Workloads We employ data sets and workloads
                                                                              from the standard benchmark TPC-H [16] and its successor TPC-
   T HEOREM 4.1. Let px be the design at the beginning of iter-               DS [15]. These benchmarks comprise analytic workloads consist-
ation x (line 3 in Figure 3) and px+1 be the design at the end of             ing of 22 and 99 query templates respectively. As a newer bench-
the iteration (line 10 in Figure 3). Assuming that DBAdv () re-               mark, TPC-DS includes more diverse and complex queries com-
turns optimal configurations, it holds that TotalCost(px , m) ≥               pared to TPC-H.
TotalCost(px+1 , m), for all x ≥ 0.                                              For both benchmarks, we create 10GB databases and correspond-
                                                                              ing query workloads using the supplied (data and query) generators
This theoretical result is interesting, since it relies solely on the op-     with the default parameters. Each workload is created as a single
timality of DBAdv () and does not make further assumptions about              query stream with all frequencies set to one, thus assigning equal
this black-box function. In practical terms, where DBAdv () is                weight to each template. For TPC-H, we create a workload with up-
imperfect but still identifies effective configurations, we have ob-          dates (termed TPC-H-u) using the 22 queries with refresh streams
served that each iteration yields a design px+1 whose performance             RF1 and RF2 at the rate of 0.1% as prescribed by the benchmark.
is either significantly better or close to px . (The details appear in        These streams contain inserts and deletes respectively that are ap-
Section 5.) Overall, the theoretical and empirical evidence suggest           plied to both the LINEITEM and ORDERS tables. We create an addi-
that the algorithm converges to a good design.                                tional update workload (termed TPC-H-u110) that has an increased
   The convergence condition (line 12) checks that the TotalCost()            proportion of queries to updates. Specifically, we concatenate five
value of the new design does not differ from the previous design              streams of 22 queries each, in addition to the refresh streams RF1
beyond a threshold , which is a parameter of the algorithm. Intu-            and RF2 mentioned above. We do not consider update workloads
itively, this is a point where the algorithm has discovered a good            for TPC-DS, as their implementation according to the benchmark
divergent design, and subsequent iterations refine this design with           is quite complicated.
diminishing returns. However, certain input instances may cause                  During our evaluation, we observed that TPC-DS queries 4 and
the algorithm to terminate only after an exponential number of iter-          11 were so expensive that they effectively obscured all other queries
ations. To avoid such problematic cases, the convergence condition            in the workload. It appeared that the the DB2 Design Advisor was
also imposes an upper bound on the number of iterations, based                unable to recommend good indexes to improve those two queries,
on a second parameter IterMax . Clearly, the two parameters con-              therefore their costs would remain the same in a uniform or diver-
trol the trade-off between total execution time of the algorithm and          gent design. Moreover, each query of the two had a cost that ex-
performance of the output partition p. Our experimental study in-             ceeded the combined costs of the remaining 97 queries. For these
dicates  = 1.0% and IterMax = 10 yields a good balance point                 reasons we exclude those two queries from our TPC-DS workload.
in practice.
   To improve the chances of discovering a good divergent design,             Experimental Parameters. Our experiments vary the following
we invoke the algorithm several times, each time starting with a              parameters: number of replicas n, load balancing factor m, and
different initial design. In this fashion we collect several designs          index configuration space budget b. Table 2 shows the values that
and return the one with the minimum TotalCost() value.                        we use in the experiments. The storage space budget is measured as
   An important detail of D IVG D ESIGN is the choice of the initial          a multiple of the base data size, i.e., given our 10 GB base data size,
partition p0 . In the current definition p0 is set as a random partition      a space budget of 1.0× indicates a 10 GB storage space budget.
(for each restart). There may be other methods of higher overhead             D IVG D ESIGN Implementation. We completed a prototype imple-
and perhaps of higher potential to improve the final output which             mentation of D IVG D ESIGN over IBM DB2 (Express-C version 9.7
are worth investigating as future work. Another important point is            for 64-bit Linux). As presented in Section 4.2, D IVG D ESIGN uti-
that the design px+1 may have sub-partitions that do not have any             lizes the system’s advisor (IBM DB2 Design Advisor, in this case)
queries. This can happen in the generation of W1x+1 , . . . , Wnx+1           to compute per-replica configurations, and the what-if optimizer to
at the end of the iteration, if no query in a previous part Wix has           estimate query costs under these configurations. In our implemen-
Iix among its best m configurations (line 9). Such designs are not            tation, we invoked the DB2 Design Advisor to compute index-only
desirable, as they reduce the effective number of replicas for query          configurations. We note that our methods are applicable for mate-
processing. Our current implementation of D IVG D ESIGN simply                rialized views as well. Since D IVG D ESIGN treats the DBAdv and
what-if query optimizer as black boxes, our implementation can be         from this setback in subsequent iterations, and this run resulted in
easily ported to another database system with these features.             the best design overall.
   We set the convergence parameters of D IVG D ESIGN to  = 1%              In all the experiments that we present, D IVG D ESIGN converged
and IterMax = 10. We actually performed minimal tuning for                to a solution within six iterations, well before the IterMax cutoff of
these settings, and therefore they are not particularly tailored to the   ten iterations. This also had a beneficial effect on running time. As
workloads that we employ. Given input parameters W , f , b, n,            an example, for the TPC-DS workload of the previous experiment
and m, we run the D IVG D ESIGN algorithm five times and output           (97 queries), D IVG D ESIGN required around three minutes per iter-
the lowest cost design out of the all the independent runs (see also      ation, leading to a maximum of 18 minutes per run. We observed
Section 4.2). We denote this final design as pdivg .                      similar run times for all other experiments.
Metrics. We measure the performance of the divergent design pdivg
(computed by D IVG D ESIGN) primarily through the value of the to-                                                        Run	
  1	
         Run	
  2	
        Run	
  3	
     Run	
  4	
     Run	
  5	
  
tal cost metric TotalCost(pdivg , m). We compute this metric by                                        155	
  
invoking the what-if optimizer to estimate the costs of queries and                                    145	
  
updates under the configurations implied by pdivg . This method-

                                                                             TotalCost	
  (x106)	
  
                                                                                                       135	
  
ology, which is consistent with previous studies on physical design
tuning, allows us to gauge the effectiveness of D IVG D ESIGN in iso-                                  125	
  
lation from any estimation errors in the optimizer’s cost models. In                                   115	
  
several cases, we report the improvement of TotalCost(pdivg , m)
compared to TotalCost(punif , m), which measures the performance                                       105	
  
of the uniform design (the current practice in real-world systems).                                      95	
  
   We also perform several experiments where we measure the wall-                                                 1	
                    2	
                  3	
              4	
               5	
        6	
  
clock time to execute workloads using the configurations corre-                                                                                             Itera2on	
  Number	
  
sponding to pdivg (again, with IBM DB2 as the DBMS). In these
experiments, we actually build the indexes corresponding to each                                        Figure 4: Five independent runs of D IVG D ESIGN.
replica. To ensure statistical robustness, we repeat these experi-
ments three times and report the average execution time.                  Diversity of output design pdivg . Next, we evaluate the diversity
Experimental Platforms. In all experiments, D IVG D ESIGN and             of the divergent design pdivg computed by D IVG D ESIGN. Diver-
IBM DB2 run on Ubuntu Linux 10.04 LTS inside a VMWare vir-                sity is a primary differentiator for divergent designs and one of the
tual machine. The virtual machine infrastructure provides the con-        key motivations behind their usage. Since our prototype imple-
venience of setting up identical environments over different host         mentation invokes the DB2 Design Advisor to compute index-only
machines.                                                                 configurations, we measure the diversity of pdivg in terms of the
   We employ two experimental platforms for the host machines.            number of distinct indexes contained in the corresponding configu-
All experiments that measure the TotalCost(pdivg , m) metric run          rations I1 , . . . , In . As a yardstick for comparison, we also measure
in a single host machine with a dual-core Intel 2.6GHz CPU and            the number of distinct indexes in the configuration Iunif of the uni-
8GB of memory. All experiments that measure wall-clock time               form design punif for the same number of replicas. Clearly, our
run on a local cluster of host machines, each having two dual-core        expectation is that pdivg should contain a significant number of ad-
AMD 2.0GHz CPUs and 8GB of RAM. The host machines in the                  ditional indexes compared to punif .
local cluster are connected with a gigabit network and switch. In            Table 3 reports the total count of distinct indexes for pdivg and
both platforms, the virtual machine running IBM DB2 is assigned           punif , for input instances with m = 1. We select m = 1 because it
2 cores and 4GB of RAM.                                                   corresponds to maximum specialization and hence maximal diver-
                                                                          sity. As shown, the number of additional indexes varies across the
5.2    Behavior of D IVG D ESIGN                                          experiments, but overall the results demonstrate that pdivg contains
                                                                          significantly more indexes compared to punif . The value of these
  The first set of experiments examines the behavior of D IVG D ESIGN
                                                                          additional indexes will become evident in the experiments that fol-
and the characteristics of the divergent designs that it computes.
                                                                          low. For a few cases we examined the indexes in punif that do not
Iterative improvement in D IVG D ESIGN. We first examine how              appear in pdivg and found that they were mostly indexes on smaller
each iteration of D IVG D ESIGN improves the currently computed           tables. Somewhat surprisingly, pdivg has a higher diversity even for
design. Theorem 4.1 states that each iteration cannot lead to a           the infinite space budget, but this is due to the imperfection of the
worse design if the DBMS advisor is optimal, so our goal is to            DB2 Design Advisor.
examine the validity of this result under the imperfect DB2 Design
Advisor. For this experiment, we employ the TPC-DS workload               5.3                             Performance for Query-Only Workloads
with b = 0.25, n = 4 and m = 1, but we obtained similar results              The next set of experiments evaluates the performance of pdvg
for other values.                                                         on query-only workloads based on the TotalCost() metric. Re-
   Figure 4 shows the TotalCost(p, m) metric at each iteration of         sults with mixed workloads of queries and updates appear in the
the algorithm, where p is the design at the end of the iteration. Each    following sub-section.
of the five curves represents an independent run of D IVG D ESIGN            Figure 5 shows the performance of pdivg as we vary the space
with a different initial (random) partition. (Recall that pdivg is the    budget and the number of replicas, for m = 1 and the TPC-H
best design out of these five runs, which is run 4 in this example.)      workload. Figure 6 shows the same results for TPC-DS. In both
   The results show that most iterations successfully improve the         cases, we report the improvement of TotalCost(pdivg , m) over
currently computed design, which matches the theoretical result of        TotalCost(punif , m), where punif is again the baseline uniform
Theorem 4.1 even though the advisor is imperfect. In fact, run 4          design for the same number of replicas. The results demonstrate a
shows a slight upward trend at the fourth iteration, which is due pre-    wide range of gains with several interesting trends. The largest per-
cisely to this imperfection. Still, D IVG D ESIGN was able to recover     formance improvements for TPC-H are 16% and 20% for n = 2
n=4	
       n=2	
                                                                                                                                                             n=4	
         n=2	
  
                                  25%	
                                                                                                                                                                     60%	
  
   TotalCost	
  Improvement	
  

                                                                                                                                                                             TotalCost	
  Improvement	
  
                                  20%	
                                                                                                                                                                     50%	
  

                                                                                                                                                                                                            40%	
  
                                  15%	
  
                                                                                                                                                                                                            30%	
  
                                  10%	
  
                                                                                                                                                                                                            20%	
  
                                   5%	
                                                                                                                                                                     10%	
  

                                   0%	
                                                                                                                                                                      0%	
  
                                                                       0.25x	
          0.5x	
                   1.0x	
            2.0x	
                INF	
                                                                                     0.25x	
            0.5x	
                   1.0x	
                 2.0x	
                INF	
  
                                                                                                         Space	
  Budget	
                                                                                                                                                              Space	
  Budget	
  

                            Figure 5: Performance of divergent design for TPC-                                                                                                                        Figure 6: Performance of divergent design for TPC-
                            H query-only workload and m = 1.                                                                                                                                          DS query-only workload and m = 1.
                                                                                           Punif	
             Pdivg-­‐one	
       Pdivg	
                                                                                                                               Punif	
             Pdivg-­‐one	
            Pdivg	
  
                                                              66	
                                                                                                                                                                      160	
  
                                                              64	
  
                                                                                                                                                                                                                                        140	
  
                                                              62	
  
                                    TotalCost	
  (x106)	
  

                                                                                                                                                                                                              TotalCost	
  (x106)	
  
                                                                                                                                                                                                                                        120	
  
                                                              60	
  
                                                              58	
                                                                                                                                                                      100	
  
                                                              56	
  
                                                                                                                                                                                                                                          80	
  
                                                              54	
  
                                                                                                                                                                                                                                          60	
  
                                                              52	
  
                                                              50	
                                                                                                                                                                        40	
  
                                                                            0.25x	
           0.5x	
                    1.0x	
                2.0x	
               INF	
                                                                                  0.25x	
                0.5x	
                    1.0x	
                2.0x	
               INF	
  
                                                                                                                Space	
  Budget	
                                                                                                                                                                Space	
  Budget	
  

                                                        Figure 8: Performance of divergent designs for TPC-                                                                                                                       Figure 9: Performance of divergent designs for TPC-
                                                        H query-only workload, n = 4, m = 2.                                                                                                                                      DS query-only workload, n = 4, m = 2.

                                                                                                   Punif	
        Pdivg	
                                                                                                                                                                                       Space Budget
                                  160	
  
                                                                                                                                                                                                                                                                                      0.25×                  0.5× 1.0× 2.0×                                     INF
                                                                                                                                                                                                                                            TPC-H, n = 2
                                  140	
  
                                                                                                                                                                                                                                                pdivg                                       27                   31              39             42              42
       TotalCost	
  (x106)	
  

                                  120	
                                                                                                                                                                                                         punif                                       22                   23              35             40              42
                                  100	
  
                                                                                                                                                                                                                                            TPC-H, n = 4
                                                                                                                                                                                                                                                pdivg                                       35                   39              42             43              43
                                     80	
                                                                                                                                                                                                       punif                                       22                   23              35             40              42
                                     60	
                                                                                                                                                                                                   TPC-DS, n = 2
                                                                                                                                                                                                                                                pdivg                                       138                165               191          229               275
                                     40	
  
                                                                                                                                                                                                                                                punif                                       119                134               154          185               269
                                                                       0.25x	
          0.5x	
                   1.0x	
               2.0x	
             INF	
  
                                                                                                                                                                                                                                            TPC-DS, n = 4
                                                                                                          Space	
  Budget	
  
                                                                                                                                                                                                                                                pdivg                                       172                197               237          275               279
Figure 7: Performance of divergent design and uniform design                                                                                                                                                                                    punif                                       119                132               152          184               268
for TPC-DS query-only workload, m = 1, n = 4.
                                                                                                                                                                                                                 Table 3: Number of distinct indexes in the configurations of
and n = 4 respectively at the 0.25× space budget. TPC-DS shows                                                                                                                                                   punif and pdivg .
a 38% improvement for n = 2 at 0.5× and 48% improvement for
n = 4 at 1.0× space budgets.                                                                                                                                                                                     beneficial indexes. We observed this to be near 2.0× for TPC-
   The general trend is that improvements increase at lower space                                                                                                                                                H and 7.5× for TPC-DS. An exception to this observation is the
budgets and also with a higher number of replicas. A divergent                                                                                                                                                   slight gain for the INF budget in Figure 5, which however can
design makes better usage of the aggregate disk space for config-                                                                                                                                                be attributed to the imperfect heuristics employed by the advisor.
urations, and can thus install more indexes than punif even at low                                                                                                                                               Overall, the improvements shown at each space budget appear to
space budgets (see also Table 3). Accordingly, as n increases, a di-                                                                                                                                             match well with the proportion of additional distinct index counts
vergent design can specialize each replica to a smaller subset of the                                                                                                                                            shown in Table 3.
workload, thus yielding better performance. It is interesting to note                                                                                                                                               Figure 7 shows in detail the performance of pdivg and punif for
that the gains are consistently higher for TPC-DS than for TPC-H.                                                                                                                                                the TPC-DS workload and n = 4. Here we chart the TotalCost()
TPC-DS is much more diverse and with far more beneficial indexes                                                                                                                                                 metric of each design. We observe that the cost of the divergent
(see again Table 3), thus the divergent design is able to partition the                                                                                                                                          design decreases rather smoothly with the larger space budgets as
workload and distribute the indexes more effectively.                                                                                                                                                            expected, exhibiting the same stable behavior as the uniform de-
   The performance gains become smaller as the space budget grows,                                                                                                                                               sign. More importantly, we observe the following interesting pat-
because at some point there is enough space to materialize all the                                                                                                                                               tern: the divergent design with a space budget of 0.25× performs
nearly the same as the uniform design with a 1.0× space budget,                                                 TPC-­‐H-­‐u110(n=4)	
     TPC-­‐H-­‐u110(n=2)	
      TPC-­‐H-­‐u(n=4)	
       TPC-­‐H-­‐u(n=2)	
  
and the same holds for the 0.5× divergent design versus the 2.0×                                             35%	
  
uniform design, and for the 1.0× divergent design versus the 5.0×                                            30%	
  

                                                                              TotalCost	
  Improvement	
  
uniform design. In other words, given four replicas, the divergent
                                                                                                             25%	
  
design for TPC-DS can perform as well as the uniform design with
                                                                                                             20%	
  
only 14 of the space budget per replica. (We obtained similar re-
sults with TPC-H.) This intuitive property validates the effective-                                          15%	
  
ness of D IVG D ESIGN in computing a good divergent design, even                                             10%	
  
though the algorithm does not have any visibility in the structure of                                         5%	
  
the workload (which is quite complicated in this experiment) or in
                                                                                                              0%	
  
the inner workings of the DBMS configuration advisor. Moreover,                                                            0.25x	
           0.5x	
            1.0x	
              2.0x	
               INF	
  
these results indicate that a divergent design may be particularly
                                                                                                                                                         Space	
  Budget	
  
beneficial if the configuration space budget is restricted.
   Our last set of experiments evaluates the effect of parameter m         Figure 10: Performance of divergent designs for TPC-H with
on the performance of the divergent designs computed by D IVG D ESIGN.     updates and m = 1.
To illustrate the trade-off between performance and load-balancing,
we consider one additional design in these experiments that we de-                                                                              Queries	
       Updates	
  

note as pone                                                                                                 80%	
  
           divg and which is the design computed by D IVG D ESIGN
for m = 1. Clearly, pone                                                                                     70%	
  
                        divg has higher specialization than pdivg and

                                                                              TotalCost	
  Improvement	
  
can thus yield better performance if every query q can be routed to                                          60%	
  
its best replica. On other hand, q may have a much higher cost on                                            50%	
  
its 2nd-best replica in pone
                          divg , which implies less flexibility in terms                                     40%	
  
of load balancing.                                                                                           30%	
  
   Figure 8 shows the TotalCost metric for designs pdivg , punif                                             20%	
  
and pone
      divg for the TPC-H workload, n = 4, m = 2. Figure 9 shows                                              10%	
  
the same results for TPC-DS. Overall, the results confirm our intu-                                           0%	
  
ition: pone
        divg has worse performance than pdivg , and in most cases it                                                       0.25x	
           0.5x	
            1.0x	
              2.0x	
               INF	
  
performs even worse that the uniform design punif . These results                                                                                        Space	
  Budget	
  
indicate that the specialization in pone
                                       divg causes great imbalance for
the cost of the same query across different replicas, thus leading to      Figure 11: Percent improvement breakdown for queries and
a high TotalCost() metric for m = 2. On the other hand, pdivg              updates in TPC-H-u110, n = 4, m = 1.
creates a specialization of replicas that directly takes into account
                                                                           u110 and n = 4. The results are shown in Figure 11. We observe
factor m, which in turn yields consistent improvements over the
                                                                           that query performance is improved by 18% at b = 0.25, but from
uniform design. The gains are small for TPC-H but very significant
                                                                           that point onwards queries have essentially the same performance
for TPC-DS, ranging from 32% to 39% over punif .
                                                                           between the divergent and uniform design. The big difference is
   To summarize, our results demonstrate that the divergent designs
                                                                           in the cost of updates, where the improvement ranges from 30% to
computed by D IVG D ESIGN outperform the baseline uniform de-
                                                                           over 70%. The reason can be traced again to the asymmetry be-
sign, often by a significant margin. The improvement is more pro-
                                                                           tween queries and updates–a query can be executed by any single
nounced with the TPC-DS workload, which is somewhat expected
                                                                           replica, whereas an update has to be executed by all replicas. Intu-
given that this workload is more complex than TPC-H and also be-
                                                                           itively, the cost to apply the update is multiplied by n. The uniform
cause IBM DB2 is heavily optimized for the execution of TPC-H
                                                                           design ignores this magnified effect and results in indexes whose
queries (as are many commercial systems).
                                                                           maintenance cost is much higher than their benefits. In contrast,
                                                                           the divergent design pdivg takes this asymmetry directly into ac-
5.4    Results with Mixed Workloads                                        count, and results in indexes that strike a better balance between
   Next we evaluate the performance of divergent designs with mixed        benefit and maintenance cost.
workloads of queries and updates. In this case, any design has to             Table 4 shows the number of indexes in pdivg and punif for b =
balance the benefits of the per-replica configurations against the         1.0 in the previous experiment, for the ORDERS and LINEITEM ta-
maintenance cost due to updates. The experiments that follow em-           bles that receive all the updates. The reported counts support our
ploy the TPC-H-u and TPC-H-u110 workloads, to evaluate the ef-             previous observation. The divergent design places far fewer in-
fect of the query-to-update ratio on the performance of divergent          dexes across the replicas, which in turn leads to reduced mainte-
designs. We first present experiments with m = 1 (highest special-         nance cost (over 50% reduction, as shown in Figure 11). Moreover,
ization) and then consider the effect of m > 1.                            we verified that pdivg comprises all the indexes of punif , except
   Figure 10 shows the percent improvement of pdivg over punif ,           that they are distributed across different replicas. It is interesting
for the two TPC-H workloads and m = 1. The gains are small for             to note that we observed similar results when we examined pdivg
TPC-H-u, since the cost of updates leads the DB2 Design Advisor            and punif for b = IN F : the divergent design installed a total of 20
to recommend relatively few indexes for both designs. Conversely,          indexes, compared to 72 indexes for the uniform design. As shown
the gains increase with the TPC-H-u110 workload, ranging from              in Figure 11, this allocation results in 70% improvement in index
19% to 33% for n = 4, since the higher percentage of queries               maintenance cost while retaining the same benefits for query eval-
justifies the creation of more indexes in the divergent design. We         uation. Thus, pdivg results in a more judicious allocation of indexes
also observe an increase in gains as n grows, which is in accordance       even when the per-replica configurations are not constrained by the
to the trend for query-only workloads.                                     space budget.
   To gain further insights on the gains of the divergent designs, we         Additional experiments considered the effect of m on the perfor-
break down the improvement per queries and updates for TPC-H-              mance of the divergent design computed by D IVG D ESIGN. We ex-
You can also read