Distributed Database Management Systems: Lecture 32. The main topics covered in this chapter include: final phase of QD; next phase of query optimization: data localization; idempotency of unary Ops; commuting selection with projection;...
Trang 1Distributed Database Management Systems
Lecture 32
Trang 2In the previous lecture
• Query Processing
• Query Decomposition
• Its Different Phases.
Trang 43- Idempotency of unary Ops
Trang 6• Many equivalence query
trees can be generated
• Comparing all such trees
to select best is not
feasible
• Heuristic is applied
Trang 71 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
Trang 8ASN PROJ EMP
x
⋈ pNo^eNo
(pName = ‘CAD/CAM’)^ ( dur = 12 v dur = 24)^ eName ’Saleem’
eName
Trang 9PROJ ASG EMP
pName = ‘CAD/CAM’ dur=12 v dur = 24 eName != ‘Saleem’
pNo, eName eName
Trang 10• This concludes Query
Trang 11• Now we move to the
second phase of Query Optimization; Data
Localization of DD
phase transform into
local ones (fragments)
Trang 13Reduction During Data
Localization
Trang 14Example Schema
• EMP(eNo, eName, title)
• Horizontal Fragmentation
• EMP1 = eNo ≤ ‘E3’ (EMP)
• EMP2 = ’E3’<eNo ≤ ‘E6’ (EMP)
• EMP3 = eNo > ‘E6’ (EMP)
Trang 15• Reduction with Selection
• Rule 1:
pi (Rj) = Ø if x in R ∀ j: (pi(x) ^ pj(x))
• That is, there exist
conflicting predicates
Trang 16• Select * from EMP where
Trang 17Reduction on Join
• Distributing joins over
unions and avoiding
unnecessary joins
• (R1UR2) ⋈ R3= (R1 ⋈
R3) U (R2 ⋈ R3)
Trang 18• Rule2:
• Ri⋈ Rj = Ø if x in R ∀ iand y in R ∀ j: (pi(x) ^
pj(x))
• Useless joins can be
determined viewing the join predicates
Trang 19• Remember! Reduced query
is not always better We
have to be
watchful-• Parallel Execution
• ASG1 = eNo ≤ ‘E3’ (ASG)ASG1 =
• ASG2 = ’eNo > ‘E3’ (ASG).ASG2 =
Trang 20• Select eName
From EMP, ASG
Where EMP.eNo = ASG eNo.
Trang 21• We already know about
Trang 24• EMP1 = eNo, eName (EMP)
• EMP2 = eNo, title (EMP)
Trang 25Rule3: D,K(Ri) is
useless if the set of
projection attributes D
is not in A‘.
Trang 28• Example
• ASG1: ASG ⋉ ENO EMP1
• ASG2: ASG ⋉ ENO EMP2
Trang 29• Query
• SELECT * FROM
EMP, ASG WHERE
ASG.eNo = EMP.eNo AND EMP.title =
"Mech Eng."
Trang 31⋈eNo
U
title = ‘Mech Eng.’
Pushing Selection Down
⋈eNo
Trang 32⋈eNo
U
title = ‘Mech Eng.’
Union Moved Up
title = ‘Mech Eng.’
⋈eNo
Trang 33title = ‘Mech Eng.’
Optimal Reduced Query
⋈eNo
Trang 34Thanks