Presentation is loading. Please wait.

Presentation is loading. Please wait.

Distributed Database Management Systems

Similar presentations


Presentation on theme: "Distributed Database Management Systems"— Presentation transcript:

1 Distributed Database Management Systems
Lecture 32

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

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

4 A1, ….,An(p(Ap)(R))  ((p(Ap) A1, ….,An, Ap(R)))-
3- Idempotency of unary Ops i) A’(A”(R))  A’(R) ii) σp1(A1)(σp2(A2)(R))  σp1(A1) ∧ p2(A2)(R)- 4- Commuting selection with projection A1, ….,An(p(Ap)(R))  ((p(Ap) A1, ….,An, Ap(R)))-

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

6 Many equivalence query trees can be generated
Comparing all such trees to select best is not feasible Heuristic is applied

7 Separation of Unary Ops
Unary ops on the same relation grouped together Unary ops commuted with binary ops Binary ops are ordered

8 ASN PROJ EMP x ⋈ pNo^eNo  (pName = ‘CAD/CAM’)^ (dur = 12 v dur = 24)^ eName ’Saleem’  eName

9 PROJ ASG EMP  pNo’  pNo, eNo  eNo, eName  pNo, eName  eName
pName = ‘CAD/CAM’ dur=12 v dur = 24 eName != ‘Saleem’  pNo’  pNo, eNo  eNo, eName  pNo, eName  eName

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

11 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)

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

13 Reduction During Data Localization

14 Example Schema EMP(eNo, eName, title) Horizontal Fragmentation
EMP1 = eNo ≤ ‘E3’ (EMP) EMP2 = ’E3’<eNo ≤ ‘E6’ (EMP) EMP3 = eNo > ‘E6’ (EMP)

15 Reduction with Selection Rule 1:
pi (Rj) = Ø if ∀x in Rj: (pi(x) ^ pj(x)) That is, there exist conflicting predicates

16 Select * from EMP where eNo = ‘E7’
U eNo = ‘E7’ EMP3 eNo = ‘E7’ Smart thinking Naïve Rule

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

18 Rule2: Ri⋈Rj = Ø if ∀x in Ri and ∀y in Rj:(pi(x) ^ pj(x)) Useless joins can be determined viewing the join predicates

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

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

21 We already know about PHF of EMP
⋈eNo ASG1 ASG2 Generic Query

22 EMP1 U ⋈eNo ASG1 EMP2 ASG2 EMP3 Reduction for PHF with JOIN

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

24 EMP1 = eNo, eName (EMP) EMP2 = eNo, title (EMP) Relation R defined over attributes A = {A1, ..., An} vertically fragmented as Ri = A' (R) where A'  A

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

26 Example: Select eName from EMP ⋈eNo Generic Query Reduced Query

27 Reduction for DF Relation R is fragmented based on the predicate on S
DF should be done for hierarchical relationship between R and S-

28 Example ASG1: ASG ⋉ ENO EMP1 ASG2: ASG ⋉ ENO EMP2 EMP1: σ title= ‘Programmer’ (EMP) EMP2: σ title “Programmer’ (EMP).

29 Query SELECT * FROM EMP, ASG WHERE ASG.eNo = EMP.eNo AND EMP.title = "Mech. Eng."

30 ASG1 ⋈eNo U ASG2 EMP1 EMP2 title = ‘Mech Eng.’ Generic Query

31 Pushing Selection Down
ASG1 ⋈eNo U ASG2 EMP2 title = ‘Mech Eng.’ Pushing Selection Down ⋈eNo

32 ASG1 ⋈eNo U EMP2 ASG2 title = ‘Mech Eng.’ Union Moved Up

33 ⋈eNo ASG2 EMP2 title = ‘Mech Eng.’ Optimal Reduced Query

34 Thanks


Download ppt "Distributed Database Management Systems"

Similar presentations


Ads by Google