8 query optimization

Upload: juitha-asry

Post on 07-Jul-2018

230 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/18/2019 8 Query Optimization

    1/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/1

    Outline•Intrdu!tin

    •Ba!"#rund

    •Distributed Database Desi#n

    •Database Inte#ratin

    •Se$anti! Data Cntrl

    •Distributed %uer Pr!essin# O'er'ie(

    %uer de!$)sitin and l!alizatin

    Distributed *uer )ti$izatin

    •Multidatabase %uer Pr!essin#

    •Distributed Transa!tin Mana#e$ent•Data +e)li!atin

    •Parallel Database Sste$s

    •Distributed Ob,e!t DBMS

    •Peer-t-Peer Data Mana#e$ent

    •eb Data Mana#e$ent

    •Current Issues

  • 8/18/2019 8 Query Optimization

    2/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/

    Ste) 0 3lbal %uerO)ti$izatinIn)ut4 5ra#$ent *uer

    •5ind the best  6nt ne!essaril )ti$al7 #lbal s!hedule

    Mini$ize a !st un!tin

    Distributed ,in )r!essin#

    Bush 's. linear trees

    hi!h relatin t shi) (here9

    Shi)-(hle 's shi)-as-needed

    De!ide n the use se$i,ins

    Se$i,in sa'es n !$$uni!atin at the e:)ense $re l!al)r!essin#.

     ;in $ethds

    nested l) 's rdered ,ins 6$er#e ,in r hash ,in7

  • 8/18/2019 8 Query Optimization

    3/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/0

    Cst-Based O)ti$izatin

    •Slutin s)a!e

     The set e*ui'alent al#ebra e:)ressins 6*uer trees7.

    •Cst un!tin 6in ter$s ti$e7

    I/O !st < CP= !st < !$$uni!atin !st  These $i#ht ha'e di>erent (ei#hts in di>erent distributed

    en'irn$ents 6?@A 's @A7.

    Can als $a:i$ize thru#h)ut

    •Sear!h al#rith$

    ( d (e $'e inside the slutin s)a!e9

    :hausti'e sear!h heuristi! al#rith$s 6iterati'e i$)r'e$entsi$ulated annealin# #eneti!E7

  • 8/18/2019 8 Query Optimization

    4/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/F

    %uer O)ti$izatin Pr!ess

    Search SpaceGeneration

    SearchStrategy

    Equivalent QEP

    Input Query

    TransformationRules

    Cost Model

    est QEP

  • 8/18/2019 8 Query Optimization

    5/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/G

    Sear!h S)a!e

    •Sear!h s)a!e !hara!terizedb alternati'e e:e!utin

    •5!us n ,in trees

    •5r N relatins there areO6NH7 e*ui'alent ,in treesthat !an be btained ba))lin# !$$utati'it andass!iati'it rules

    SELECT ENAME,RESP

    FROM  EMP, ASG,PROJ

     WHERE   EMP.ENO=ASG.ENO

     AND ASG.PNO=PROJ.PNO

    PR!"

     #SGEMP

    PR!"  #SG

    EMP

    PR!"

     #SG

    EMP

    ▷◁ P$!

    ▷◁E$!

    ▷◁ P$!

    ▷◁ E$!

    ▷◁E$!%P$!

  • 8/18/2019 8 Query Optimization

    6/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/J

    Sear!h S)a!e

    +estri!t b $eans heuristi!s

    Perr$ unar )eratins bere binar )eratins

    E

    +estri!t the sha)e the ,in tree Cnsider nl linear trees i#nre bush nes

    &inear "oin Tree ushy "oin Tree

    R 'R (

    R )

    R *

    R 'R (   R *R )

    K

    KK

    KK K

  • 8/18/2019 8 Query Optimization

    7/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/L

    Sear!h Strate#

    ( t $'eN in the sear!h s)a!e.

    Deter$inisti!

    Start r$ base relatins and build )lans b addin# ne relatin atea!h ste)

    Dna$i! )r#ra$$in#4 breadth-rst

    3reed4 de)th-rst

    +and$ized

    Sear!h r )ti$alities arund a )arti!ular startin# )int

     Trade )ti$izatin ti$e r e:e!utin ti$e

    Better (hen 1Q relatins

    Si$ulated annealin#

    Iterati'e i$)r'e$ent

  • 8/18/2019 8 Query Optimization

    8/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/8

    Sear!h Strate#ies

    •Deter$inisti!

    R 'R (

    R )

    R *

    R 'R (   R 'R (

    R )

    R 'R (

    R )

    R )R (

    R '

    •+and$ized

    KK

    K

    K

    K

    K

    KK K

    K

  • 8/18/2019 8 Query Optimization

    9/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/R

    Cst 5un!tins

    • Ttal Ti$e 6r Ttal Cst7

    +edu!e ea!h !st 6in ter$s ti$e7 !$)nent indi'iduall

    D as little ea!h !st !$)nent as )ssible

    O)ti$izes the utilizatin the resur!es

    In!reases sste$ thru#h)ut

    •+es)nse Ti$e

    D as $an thin#s as )ssible in )arallel Ma in!rease ttal ti$e be!ause in!reased ttal a!ti'it

  • 8/18/2019 8 Query Optimization

    10/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/1Q

     Ttal Cst

    Su$$atin all !st a!trs

     Ttal !st CP= !st < I/O !st < !$$uni!atin !st

    CP= !st unit instru!tin !st ∗ n. instru!tins

    I/O !st unit dis" I/O !st ∗ n. dis" I/Os

    !$$uni!atin !st $essa#e initiatin < trans$issin

  • 8/18/2019 8 Query Optimization

    11/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/11

     Ttal Cst 5a!trs

    •ide area net(r"

    Messa#e initiatin and trans$issin !sts hi#h

    ?!al )r!essin# !st is l( 6ast $ainra$es r

    $ini!$)uters7 +ati !$$uni!atin t I/O !sts Q41

    •?!al area net(r"s

    C$$uni!atin and l!al )r!essin# !sts are $re r less

    e*ual +ati 141.J

  • 8/18/2019 8 Query Optimization

    12/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/1

    +es)nse Ti$e

    la)sed ti$e bet(een the initiatin and the !$)letin a *uer

    +es)nse ti$e CP= ti$e < I/O ti$e < !$$uni!atin ti$e

    CP= ti$e unit instru!tin ti$e n. se*uentialinstru!tins

    I/O ti$e unit I/O ti$e  n. se*uential I/Os

    !$$uni!atin ti$e unit $s# initiatin ti$e  n.

    se*uential $s#< unit trans$issin ti$e  n. se*uential 

    btes

  • 8/18/2019 8 Query Optimization

    13/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/10

    :a$)le

    @ssu$e that nl the !$$uni!atin !st is !nsidered

     Ttal ti$e  ×$essa#e initializatin ti$e < unit trans$issin ti$e  6 x+y 7

    +es)nse ti$e $a: Uti$e t send x  r$ 1 t 0 ti$e t send y  r$ t 0

    ti$e t send x  r$ 1 t 0 $essa#e initializatin ti$e< unit trans$issin ti$e   x 

    ti$e t send y  r$ t 0 $essa#e initializatin ti$e< unit trans$issin ti$e   y 

    Site (

    Site '

     x  units

    y  units

    Site )

  • 8/18/2019 8 Query Optimization

    14/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/1F

    O)ti$izatin Statisti!s

    •Pri$ar !st a!tr4 size inter$ediate relatins Aeed t esti$ate their sizes

    •Ma"e the$ )re!ise ⇒$re !stl t $aintain

    •Si$)liin# assu$)tin4 unir$ distributin attribute 'alues in

    a relatin

  • 8/18/2019 8 Query Optimization

    15/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/1G

    Statisti!s

    •5r ea!h relatin RW A1 A E AnX ra#$ented as R1 E Rr  len#th ea!h attribute4 length6 Ai7

    the nu$ber distin!t 'alues r ea!h attribute in ea!hra#$ent4 card6Π AiR j7

    $a:i$u$ and $ini$u$ 'alues in the d$ain ea!h attribute4min6 Ai7 ma:6 Ai7

    the !ardinalities ea!h d$ain4 card6domW AiX7

    • The !ardinalities ea!h ra#$ent4 card6R j7 Sele!ti'it a!tr

    ea!h )eratin r relatins 5r ,ins

    SF  K 6RS7

    card6R 

    KS7card6R7 ∗ card6S7

  • 8/18/2019 8 Query Optimization

    16/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/1J

    Inter$ediate +elatin Sizes

    Sele!tin

    size6R7 card6R7 ×length6R7

    card6σF 6R77 SF σ6F 7 ×card6R7

    (here S F σ6 A value7 card6Y A6R77

    1

    S F σ6 A value7 max 6 A7 min6 A7

    max 6 A7 value

    S F σ

    6 A Zvalue7 max 6 A7 min6 A7

    value – max 6 A7

    SF σ6 p6 Ai7∧ p6 A j77 SF σ6 p6 Ai77 ×SF σ6 p6 A j77

    SF σ6 p6 Ai7 ∨ p6 A j77 SF σ6 p6 Ai77 < SF σ6 p6 A j77 6SF σ6 p6 Ai77 ×SF σ6 p6 A j777

    SF σ6 A∈{value7 SF σ6 A value7  card6Uvalues7

  • 8/18/2019 8 Query Optimization

    17/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/1L

    Inter$ediate +elatin Sizes

    Pr,e!tin

    card6Π A6R77card6R7

    Cartesian Prdu!t

    card6R ×S7 card6R7  card6S7=nin

    u))er bund4 card6R ∪ S7 card6R7 < card6S7

    l(er bund4 card6R ∪ S7 max Ucard6R7 card6S7

    Set Di>eren!eu))er bund4 card6RS7 card6R7

    l(er bund4 Q

  • 8/18/2019 8 Query Optimization

    18/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/18

    Inter$ediate +elatin Size

     ;in

    S)e!ial !ase4 A is a "e R and B is a rei#n "e S

    card6R K AB S7 card6S7

    Mre #eneral4card6R K S7 SF K  card6R7 ×card6S7

    Se$i,in

    card6R [ A S7 SF [6S!A7  card6R7

    (here

    SF [6R [ A S7 SF [6S!A7 card6Y A6S77card6domW AX7

  • 8/18/2019 8 Query Optimization

    19/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/1R

    ist#ra$s r Sele!ti'itsti$atin•5r s"e(ed data the unir$ distributin assu$)tin attribute

    'alues ields ina!!urate esti$atins

    •=se an hist#ra$ r ea!h s"e(ed attribute @

    ist#ra$ set bu!"ets

    a!h bu!"et des!ribes a ran#e 'alues @ (ith its a'era#e

    re*uen! "  6nu$ber tu)les (ith @ in that ran#e7 and nu$ber

    distin!t 'alues d

    Bu!"ets !an be ad,usted t di>erent ran#es

    •:a$)les *ualit )redi!ate

    ith 6'alue in +an#ei7 (e ha'e4 SF σ  6 A value7 1 #di

    +an#e )redi!ate

    +e*uires identiin# rele'ant bu!"ets and su$$in# u) their

    re*uen!ies

  • 8/18/2019 8 Query Optimization

    20/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/Q

    ist#ra$ :a$)le

    5r @S3.D=+184 (e ha'e S51/1 s the !ard sele!tin is0QQ/1 G tu)les

    5r @S3.D=+\184 (e ha'e $in6ran#e071 and$a:6ran#e

    0

    7F s the !ard. sele!tin is 1QQ

  • 8/18/2019 8 Query Optimization

    21/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/1

    Centralized %uerO)ti$izatin•Dna$i! 6In#res )r,e!t at =CB7

    Inter)reti'e

    •Stati! 6Sste$ + )r,e!t at IBM7

    :hausti'e sear!h

    •brid 6Vl!an )r,e!t at O3I7

    Chse nde (ithin )lan

  • 8/18/2019 8 Query Optimization

    22/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/

    Dna$i! @l#rith$

    De!$)se ea!h $ulti-'ariable *uer int a se*uen!e $n-'ariable *ueries (ith a !$$n 'ariable

    Pr!ess ea!h b a ne 'ariable *uer )r!essr Chse an initial e:e!utin )lan 6heuristi!s7

    Order the rest b !nsiderin# inter$ediate relatin sizes

    A statisti!al inr$atin is $aintained

  • 8/18/2019 8 Query Optimization

    23/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/0

    Dna$i! @l#rith$De!$)sitin•+e)la!e an n 'ariable *uer $ b a series *ueries

    $1→$ → E → $n

    (here $i uses the result $i-1.

    •Deta!h$ent %uer $ de!$)sed int $% → $& (here $% and $& ha'e a !$$n

    'ariable (hi!h is the result $%

    • Tu)le substitutin

    +e)la!e the 'alue ea!h tu)le (ith a!tual 'alues and si$)li the*uer

    $6' 1 '  ... ' n7 → 6$% 6t 1 '  '  ... ' n7 t 1∈R7

  • 8/18/2019 8 Query Optimization

    24/53Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/F

    Deta!h$ent

    $4   SELECT V 2.A 

    2,V 

    3.A 

    3, …,V 

    n.A 

    n

    FROM R1V 1, …,R

    nV n

     WHERE P 1(V 

    1.A 

    1’) AND P 

    2(V 

    1.A 

    1,V 

    2.A 

    2,…, V 

    n.A 

    n)

    ⇓$%4   SELECT V 

    1.A 

    1INTO R

    1'

    FROM R1V 1

     WHERE P 1(V 1.A 1)

    $&4 SELECT V 2.A 

    2, …,V 

    n.A 

    n

    FROM R1' V 

    1, R

    2V 2, …,R

    nV n

     WHERE P 2(V 

    1.A 

    1, V 

    2.A 

    2, …,V 

    n.A 

    n)

  • 8/18/2019 8 Query Optimization

    25/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/G

    Deta!h$ent :a$)leAa$es e$)lees (r"in# n C@D/C@M )r,e!t

    $14   SELECT EMP.ENAME

    FROM  EMP, ASG, PROJ

     WHERE   EMP.ENO=ASG.ENO

     AND ASG.PNO=PROJ.PNO

     AND PROJ.PNAME="CAD/CAM"

    ⇓$114 SELECT PROJ.PNO INTO JVAR

    FROM  PROJ

     WHERE   PROJ.PNAME="CAD/CAM"

    $%4   SELECT EMP.ENAMEFROM  EMP,ASG,JVAR

     WHERE   EMP.ENO=ASG.ENO

     AND ASG.PNO=JVAR.PNO

  • 8/18/2019 8 Query Optimization

    26/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/J

    Deta!h$ent :a$)le6!nt^d7

    $%4   SELECT EMP.ENAME

    FROM  EMP,ASG,JVAR

     WHERE   EMP.ENO=ASG.ENO

     AND  ASG.PNO=JVAR.PNO

    ⇓$14 SELECT ASG.ENO INTO GVAR

    FROM  ASG,JVAR

     WHERE   ASG.PNO=JVAR.PNO

    $104 SELECT EMP.ENAME

    FROM  EMP,GVAR

     WHERE   EMP.ENO=GVAR.ENO

  • 8/18/2019 8 Query Optimization

    27/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/L

     Tu)le Substitutin

    $11 is a $n-'ariable *uer

    $1  and $10 is sub,e!t t tu)le substitutin

    @ssu$e GVAR has t( tu)les nl4 〈 E1  〉 and 〈 E2〉

     Then $10  be!$es$1014 SELECT EMP.ENAME

    FROM  EMP

     WHERE   EMP.ENO="E1"

    $104 SELECT EMP.ENAME

    FROM  EMP

     WHERE   EMP.ENO="E2"

  • 8/18/2019 8 Query Optimization

    28/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/8

    Stati! @l#rith$

    Si$)le 6i.e. $n-relatin7 *ueries are e:e!uted a!!rdin# t thebest a!!ess )ath

    :e!ute ,ins

    Deter$ine the )ssible rderin# ,ins Deter$ine the !st ea!h rderin#

    Chse the ,in rderin# (ith $ini$al !st

  • 8/18/2019 8 Query Optimization

    29/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/R

    Stati! @l#rith$

    5r ,ins t( alternati'e al#rith$s 4

    •Aested l)s

    for each tu)le external relatin 6!ardinalit n17

    for each tu)le internal relatin 6!ardinalit n7

     ,in t( tu)les i the ,in )redi!ate is true

    end

    end

    C$)le:it4 n1 n

    •Mer#e ,in

    srt relatins

    $er#e relatins

    C$)le:it4 n1< n i relatins are )re'iusl srted and e*ui,in

  • 8/18/2019 8 Query Optimization

    30/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/0Q

    Stati! @l#rith$ :a$)le

    Aa$es e$)lees (r"in# n the C@D/C@M )r,e!t

    @ssu$e

    MP has an inde: n AO

    @S3 has an inde: n PAO

    P+O; has an inde: n PAO and an inde: n PA@M

    P$!E$!

    PR!"

     #SG

    EMP

  • 8/18/2019 8 Query Optimization

    31/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/01

    :a$)le 6!nt^d7 Chse the best a!!ess )aths t ea!h relatin

    MP4 se*uential s!an 6n sele!tin n MP7

    @S34 se*uential s!an 6n sele!tin n @S37

    P+O;4 inde: n PA@M 6there is a sele!tin n P+O; based n

    PA@M7Deter$ine the best ,in rderin#

    MP ▷◁ @S3 ▷◁ P+O;

    @S3 ▷◁P+O; ▷◁ MP

    P+O;▷◁

    @S3▷◁

     MP @S3 ▷◁MP ▷◁ P+O;

    MP P+O; ▷◁ @S3

    P+O   ;MP ▷◁@S3

    Sele!t the best rderin# based n the ,in !sts e'aluateda!!rdin# t the t( $ethds

  • 8/18/2019 8 Query Optimization

    32/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/0

    Stati! @l#rith$

    Best ttal ,in rder is ne  

    66@S3 K MP7 K P+O;766P+O; K @S37 K MP7

     #SGEMP PR!"

    EMP  PR!"pruned

    PR!"  EMPpruned

    @lternati'es

    EMP K  #SGpruned

    +#SG

    KEMP,

    KPR!"

     #SG K EMP#SG K PR!"pruned

    PR!" K #SG

    +PR!"

    K #SG,

    KEMP

  • 8/18/2019 8 Query Optimization

    33/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/00

    Stati! @l#rith$

    •66P+O; K @S37 K MP7 has a useul inde: n the sele!t attributeand dire!t a!!ess t the ,in attributes @S3 and MP

    • Therere !hse it (ith the ll(in# a!!ess $ethds4

    sele!t P+O; usin# inde: n PA@M

    then ,in (ith @S3 usin# inde: n PAO

    then ,in (ith MP usin# inde: n AO

  • 8/18/2019 8 Query Optimization

    34/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/0F

    brid )ti$izatin

    •In #eneral stati! )ti$izatin is $re e_!ient than dna$i!)ti$izatin

    @d)ted b all !$$er!ial DBMS

    •But e'en (ith a s)histi!ated !st $del 6(ith hist#ra$s7

    a!!urate !st )redi!tin is di_!ult

    •:a$)le

    Cnsider a )ara$etri! *uer (ith )redi!ate

      + +.@ `a / `a is a )ara$eter

     The nl )ssible assu$)tin at !$)ile ti$e is unir$ distributin 'alues

    •Slutin4 brid )ti$izatin

    Chse-)lan dne at runti$e based n the a!tual )ara$eterbindin#

  • 8/18/2019 8 Query Optimization

    35/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/0G

    brid O)ti$izatin :a$)le

    -a.#

    -a.#

  • 8/18/2019 8 Query Optimization

    36/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/0J

     ;in Orderin# in 5ra#$ent%ueries•Orderin# ,ins

    Distributed IA3+S

    Sste$ +

     T(-ste)

    •Se$i,in rderin#

    SDD-1

  • 8/18/2019 8 Query Optimization

    37/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/0L

     ;in Orderin#

    •Multi)le relatins $re di_!ult be!ause t $an alternati'es.

    C$)ute the !st all alternati'es and sele!t the best ne. Ae!essar t !$)ute the size inter$ediate relatins (hi!h is

    di_!ult.

    =se heuristi!s

    if size+R , / size+S,

    if size+R , 0 size+S, S

    •Cnsider t( relatins nl

  • 8/18/2019 8 Query Optimization

    38/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/08

     ;in Orderin# :a$)le

    Cnsider

    P+O; KPAO @S3 KAO MP

    Site '

    Site )Site (

    P$!E$!

    PR!"

     #SG

    EMP

  • 8/18/2019 8 Query Optimization

    39/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/0R

     ;in Orderin# :a$)le:e!utin alternati'es41.MP→ Site . @S3 → Site 1

    Site !$)utes MPMP K @S3 Site 1 !$)utes MPMP K@S3

    MP→ Site 0 MP → Site 0Site 0 !$)utes MP K P+O; Site 0 !$)utes MP^ K P+O;

    0.@S3 → Site 0F. P+O; → Site

    Site 0 !$)utes @S3@S3 K P+O; Site !$)utes P+O;P+O; 

    K @S3@S3 → Site 1 P+O; → Site 1

    Site 1 !$)utes @S3 ▷◁ MP Site 1 !$)utes P+O; K MP

    G.MP →  Site

  • 8/18/2019 8 Query Optimization

    40/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/FQ

    Se$i,in @l#rith$s

    •Cnsider the ,in t( relatins4

    RW AX 6l!ated at site 17

    SW AX6l!ated at site 7

    •@lternati'es4

    1. D the ,in R K AS

    . Perr$ ne the se$i,in e*ui'alents

    R K A

    S ⇔ 6R [ A

    S7 K A

    S

    ⇔ R K A 6S [ A R7

    ⇔ 6R [ A S7 K A 6S [ A R7

  • 8/18/2019 8 Query Optimization

    41/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/F1

    Se$i,in @l#rith$s

    •Perr$ the ,in

    send R t Site

    Site !$)utes R K A S

    •Cnsider se$i,in 6R [ AS7 K AS

    S%  Π A6S7

    S% → Site 1

    Site 1 !$)utes R% R [ AS%

    R%→ Site Site !$)utes R% K AS

    Se$i,in is better i 

    size6Π A6S77 < size6R [ AS77 Z size6R7

  • 8/18/2019 8 Query Optimization

    42/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/F

    Distributed Dna$i!@l#rith$1. :e!ute all $nrelatin *ueries 6e.#. sele!tin )r,e!tin7. +edu!e the $ultirelatin *uer t )rdu!e irredu!ible

    sub*ueries$1→ $ →E → $nsu!h that there is nl ne relatin bet(een $i 

    and $i

  • 8/18/2019 8 Query Optimization

    43/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/F0

    Stati! @))ra!h

    •Cst un!tin in!ludes l!al )r!essin# as (ell as trans$issin

    •Cnsiders nl ,ins

    •:hausti'eN sear!h

    •C$)ilatin

    •Published )a)ers )r'ide slutins t handlin# hrizntal and'erti!al ra#$entatins but the i$)le$ented )rtt)e des nt

  • 8/18/2019 8 Query Optimization

    44/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/FF

    Stati! @))ra!h Perr$in# ;ins•Shi) (hle

    ?ar#er data transer

    S$aller nu$ber $essa#es

    Better i relatins are s$all•5et!h as needed

    Au$ber $essa#es (6!ardinalit e:ternal relatin7

    Data transer )er $essa#e is $ini$al

    Better i relatins are lar#e and the sele!ti'it is #d

    i h

  • 8/18/2019 8 Query Optimization

    45/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/FG

    Stati! @))ra!h Verti!al Partitinin# & ;ins1. M'e uter relatin tu)les t the site the inner relatin

    6a7 +etrie'e uter tu)les

    6b7 Send the$ t the inner relatin site

    6!7 ;in the$ as the arri'e

     Ttal Cst !st6retrie'in# *ualied uter tu)les7< n. uter tu)les et!hed  !st6retrie'in#

    *ualied inner tu)les7< $s#. !st  6n. uter tu)les et!hed   a'#.

    uter tu)le size7/$s#. size

    i h

  • 8/18/2019 8 Query Optimization

    46/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/FJ

    Stati! @))ra!h Verti!al Partitinin# & ;ins. M'e inner relatin t the site uter relatin

    Cannt ,in as the arri'e the need t be stred

     Ttal !st !st6retrie'in# *ualied uter tu)les7< n. uter tu)les et!hed  !st6retrie'in#

    $at!hin# inner tu)les r$ te$)rarstra#e7< !st6retrie'in# *ualied inner tu)les7< !st6strin# all *ualied inner tu)les inte$)rar stra#e7

    < $s#. !st  n. inner tu)les et!hed a'#. inner tu)le size/$s#. size

    S i @ h

  • 8/18/2019 8 Query Optimization

    47/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/FL

    Stati! @))ra!h Verti!al Partitinin# & ;ins0. M'e bth inner and uter relatins t anther site

     Ttal !st !st6retrie'in# *ualied uter tu)les7< !st6retrie'in# *ualied inner tu)les7

    < !st6strin# inner tu)les in stra#e7< $s#. !st ×6n. uter tu)les et!hed  a'#. uter tu)le size7/$s#. size< $s#. !st  6n. inner tu)les et!hed  a'#. inner tu)le size7/$s#. size

    < n. uter tu)les et!hed  !st6retrie'in#inner tu)les r$ te$)rar stra#e7

  • 8/18/2019 8 Query Optimization

    48/53

    D i St ti

  • 8/18/2019 8 Query Optimization

    49/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/FR

    Dna$i! 's. Stati! 'sSe$i,in•Se$i,in

    SDD1 sele!ts nl l!all )ti$al s!hedules

    •Dna$i! and stati! a))ra!hes ha'e the sa$e ad'anta#es anddra(ba!"s as in !entralized !ase

    But the )rble$s a!!urate !st esti$atin at !$)ile-ti$e are$re se'ere

    Mre 'ariatins at runti$e

    +elatins $a be re)li!ated $a"in# site and !) sele!tin i$)rtant

    •brid )ti$izatin Chse-)lan a))ra!h !an be used

    -ste) a))ra!h si$)ler

  • 8/18/2019 8 Query Optimization

    50/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/GQ

    -Ste) O)ti$izatin

    1. @t !$)ile ti$e #enerate a stati! )lan (ith )eratin rderin#and a!!ess $ethds nl

    . @t startu) ti$e !arr ut site and !) sele!tin and all!ate)eratins t sites

  • 8/18/2019 8 Query Optimization

    51/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/G1

    -Ste) Prble$ Denitin

    •3i'en

    @ set sites S Us1 s Esn (ith the lad ea!h site

    @ *uer ) U$1* $* $0* $F su!h that ea!h sub*uer $i is the$a:i$u$ )r!essin# unit that a!!esses ne relatin and

    !$$uni!ates (ith its nei#hbrin# *ueries 5r ea!h $i in ) a easible all!atin set sites S$Us1 s Es 

    (here ea!h site stres a !) the relatin in $i

    • The b,e!ti'e is t nd an )ti$al all!atin ) t S su!h that

    the lad unbalan!e S is $ini$ized  The ttal !$$uni!atin !st is $ini$ized

  • 8/18/2019 8 Query Optimization

    52/53

    Distributed DBMS © M. T. Özsu & P. Valduriez Ch.8/G

    -Ste) @l#rith$

    • 5r ea!h $ in ) !$)ute lad 6S$7

    • hile ) nt e$)t d

    1. Sele!t sub*uer a (ith least all!atin ce:ibilit

    . Sele!t best site b r a 6(ith least lad and best benet7

    0. +e$'e a r$ ) and re!$)ute lads i needed

  • 8/18/2019 8 Query Optimization

    53/53