Distributed Database Management Systems: Lecture 31. The main topics covered in this chapter include: query decomposition; steps in query processing; SQL query on distributed relations; optimized fragment query with communication operations;...
Distributed Database Management Systems Lecture 31 In the previous lecture • Basic Concepts of Query Optimization • QP in centralized and Distributed DBs In this Lecture • Query Decomposition • Its Phases • …… Steps in Query Processing SQL Query on Distributed Relations QUERY DECOMPOSITION Algebraic Query on Distributed Relations DATA LOCALIZATION GLOBAL SCHEMA FRAGMENT SCHEMA Fragment Query GLOBAL OPTIMIZATION Optimized Fragment Query with Communication Operations LOCAL OPTIMIZATION Optimized Local Query STAT OF FRAGMENTS LOCAL SCHEMA Query Decomposition • Transforms an SQL (relational calculus) query into relational algebra query • Both are on global relations in DDBS- Steps in QD Normalization Analysis Simplification Rewriting 1- Normalization • Input Query can be complex • Lexical and syntactic Analysis (like compilers) • Treatment of WHERE Clause • Two possible forms- • Conjunctive NF–(p11vP12v….vp1n) ^ … ^(pm1vpm2v….vpmn) • Disjunctive NF –(p11^P12^….^p1n) v… v(pm1^pm2^….^pmn) • Transformation is based on equivalence rules Equivalence Rules • p1 ^ p2 p2 ^ p1 • p1 v p p v p • (p1 ^ p2) ^ p3 p1 ^ (p2 ^ p3) • (p1 v p2) v p3 p1 v ( p2 v p3) • p1 ^ (p2v p3) (p1 ^ p2)v(p1 ^ p3) • p1 v (p2 ^ p3) (p1 v p2)^(p1 v p3) V into U and ^ into ⋈ or Example • SELECT eName FROM EMP, ASG WHERE EMP.eNo = ASG.eNo AND ASG.pNo = ‘P1’ AND dur = 12 OR dur = 24 5- Commuting Selection with binary ops, like join and CP 6- Commuting Projection with binary ops, like join and CP • Many eq 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 QP that comprises steps • Now we move to the second phase of Query Optimization; Data Localization of DD • QD at global level, this phase transform into local ones • 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’ ‘E3’ (ASG) –θ ∈{=, , ≥} ∈ – – ←Ø⇒ ⋉ ⋈ ∪ ∀ ^ ... previous lecture • Basic Concepts of Query Optimization • QP in centralized and Distributed DBs In this Lecture • Query Decomposition • Its Phases • …… Steps in Query Processing SQL Query on Distributed. .. Steps in Query Processing SQL Query on Distributed Relations QUERY DECOMPOSITION Algebraic Query on Distributed Relations DATA LOCALIZATION GLOBAL SCHEMA FRAGMENT SCHEMA Fragment Query GLOBAL OPTIMIZATION