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;...
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 Separation of Unary Ops Unary ops on the same relation grouped together Unary ops commuted with binary ops 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 • 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‘ • Example: • Select eName from EMP eName ⋈ eName e No EMP1 EMP2 Generic Query EMP1 Reduced Query Reduction for DF • Relation R is fragmented based on the predicate on S • DF should be done for hierarchical relationship between R and S- • Example • ASG1: ASG ⋉ ENO EMP1 • ASG2: ASG ⋉ ENO EMP2 • EMP1: σ title= ‘Programmer’ (EMP) • EMP2: σ title “Programmer’ (EMP) • Query • SELECT * FROM EMP, ASG WHERE ASG.eNo = EMP.eNo AND EMP.title = "Mech Eng." ⋈eNo title = ‘Mech Eng.’ U U ASG1 ASG2 EMP1 Generic Query EMP2 ⋈eNo U ASG1 ASG2 title = ‘Mech Eng.’ EMP2 Pushing Selection Down U ⋈eNo ⋈eNo title = ‘Mech Eng.’ title = ‘Mech Eng.’ ASG1 EMP2 ASG2 Union Moved Up EMP2 ⋈eNo title = ‘Mech Eng.’ ASG2 EMP2 Optimal Reduced Query Thanks ...In the previous lecture • Query Processing • Query Decomposition • Its Different Phases In this Lecture • Final phase of QD • Next phase of Query Optimization:... 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