Tải bản đầy đủ (.pdf) (34 trang)

Distributed Database Management Systems: Lecture 32

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (105.04 KB, 34 trang )

Distributed Database
Management Systems
Lecture 32


In the previous lecture
• Query Processing
• Query Decomposition
• Its Different Phases.


In this Lecture
• Final phase of QD
• Next phase of Query
Optimization: Data
Localization.


3- Idempotency of unary Ops

(R))
A’(R)
ii) σp1(A1)(σp2(A2)(R))
i)

A’

(

A”


σp1(A1) ∧ p2(A2)(R)-

4- Commuting selection with
projection

(R))
A1, ….,An, Ap(R)))-

A1, ….,An

(

p(Ap)

((

p(Ap)


5- Commuting
Selection with binary
ops, like join and CP
6- Commuting
Projection with binary
ops, like join and CP


• Many equivalence query
trees can be generated
• Comparing all such trees

to select best is not
feasible
• Heuristic is applied


1. Separation of Unary Ops
2. Unary ops on the same
relation grouped together
3. Unary ops commuted with
binary ops
4. Binary ops are ordered


eName

(pName = ‘CAD/CAM’)^ (dur = 12 v dur = 24)^ eName

’Saleem’

⋈ pNo^eNo
x
ASN

PROJ

EMP


eName


pNo, eName

pNo’

pName = ‘CAD/CAM’

PROJ

pNo, eNo

dur=12 v dur = 24

ASG

eNo, eName

eName != ‘Saleem’

EMP


• This concludes Query
Decomposition and
Restructuring
• Query Decomposition
• Concerns both centralized
and distributed
environments



• Now we move to the
second phase of Query
Optimization; Data
Localization of DD
• QD at global level, this
phase transform into
local ones (fragments)


• Called Localization
Program
• A Naïve rule…
• However, it won’t be
an efficient one


Reduction During Data
Localization


Example Schema
• EMP(eNo, eName, title)
• Horizontal Fragmentation
• EMP1 =

eNo ≤ ‘E3’

• EMP2 =

’E3’


• EMP3 =

eNo > ‘E6’

(EMP)
(EMP)

(EMP)


• Reduction with Selection
• Rule 1:
(R
)
=
Ø
if

x
in
R
:
j
j
pi
(pi(x) ^ pj(x))
• That is, there exist
conflicting predicates



• Select * from EMP where
eNo = ‘E7’
eNo = ‘E7’
eNo = ‘E7’

U
EMP3
EMP1 EMP2 EMP3

Naïve Rule

Smart thinking


Reduction on Join
• Distributing joins over
unions and avoiding
unnecessary joins
• (R1UR2) ⋈ R3= (R1 ⋈

R3) U (R2 ⋈ R3)


• Rule2:
• Ri⋈Rj = Ø if ∀x in Ri
and ∀y in Rj: (pi(x) ^
pj(x))

• Useless joins can be

determined viewing
the join predicates


• Remember! Reduced query
is not always better. We
have to be watchful• Parallel Execution
• ASG1 = eNo ≤ ‘E3’ (ASG)
• ASG2 = ’eNo > ‘E3’ (ASG).


• Select eName
From EMP, ASG
Where EMP.eNo =
ASG. eNo.


• We already know about
PHF of EMP

eNo

U

EMP1 EMP2 EMP3

U

ASG1


Generic Query

ASG2


U







No

No

No

e

EMP1

e

ASG1 EMP2

ASG2

e


EMP3

ASG2

Reduction for PHF with JOIN


Reduction for VF
• Relation fragmented on
projection, with PK as
the common attribute
• Localization involves
natural join on PK


• EMP1 =

eNo, eName

• EMP2 =

eNo, title

(EMP)

(EMP)

• Relation R defined over
attributes A = {A1, ..., An}

vertically fragmented as Ri
= A' (R) where A' A


Rule3: D,K(Ri) is
useless if the set of
projection attributes D
is not in A‘.


×