ADB - Unit - III (Chapter-2) - Query Processing and Decomposition
ADB - Unit - III (Chapter-2) - Query Processing and Decomposition
query
processor
➡ SQL
➡ The steps that one goes through in executing high-level (declarative) user
queries.
• Query optimization
SELECT ENAME
FROM EMP,ASG
WHERE EMP.ENO = ASG.ENO
AND RESP = "Manager“
Strategy 1
ENAME(RESP=“Manager”EMP.ENO=ASG.ENO(EMP×ASG))
Strategy 2
ENAME(EMP ⋈ENO (RESP=“Manager” (ASG))
Site 5
Strategy-B
Strategy-A Site 5
result EMP1' EMP2' result= (EMP1 × EMP2)⋈ENOσRESP=“Manager”(ASG1× ASG2)
EMP1' EMP2'
Site 3 Site 4 ASG1 ASG2 EMP1 EMP2
EMP’1=EMP1 ⋈ENO ASG’1 EMP’2=EMP2 ⋈ENO ASG’2
Site 1 Site 2 Site 3 Site 4
• Languages
• Types of Optimizers
• Optimization Timing
• Statistics
• Decision Sites
• Network Topology
• Replicated Fragments
• Use of Semijoins
Distributed DBMS © M. T. Özsu & P. Valduriez Ch.6/10
Characteristics of Query Processors
Complexity of Relational Operations
Operation Complexity
Select
• Assume Project O(n)
(without duplicate elimination)
➡ relations of cardinality n
➡ sequential scan Project
(with duplicate elimination) O(n log n)
Group
Join
Semi-join O(n log n)
Division
Set Operators
➡ Optimal
• Heuristics
➡ Not optimal
• Distributed
➡ Cooperation among sites to determine the schedule
➡ Need only local information
➡ Cost of cooperation
• Hybrid
➡ One site determines the global schedule
➡ Each site optimizes the local subqueries
Query GLOBAL
Decomposition SCHEMA
Fragment Query
Global STATS ON
Optimization FRAGMENTS
ASG ASG
EMP.ENO=ASG.ENO ASG.PNO=PROJ.PNO EMP.ENO=ASG.ENO ASG.PNO=PROJ.PNO
TITLE =
EMP RESP PROJ EMP PROJ
“Programmer”
ENAME
RESULT
PNAME=“CAD/CAM”
ASG
ENAME
RESULT
PNAME=“CAD/CAM”
➡ Elimination of redundancy
✦ idempotency rules
p1 ¬( p1) false
p1 (p1p2) p1
p1 false p1
…
➡ Application of transitivity
➡ Use of integrity rules
SELECT TITLE
FROM EMP
WHERE EMP.ENAME = "J. Doe"
⋈PNO,ENO
➡ optimize
SELECT ENAME
FROM EMP
ENAME ENAME
⋈ENO
TITLE=“Mech. Eng.”
⋈ENO ⋈ENO
TITLE=“Mech. Eng.”
ASG2 EMP2
Distributed DBMS © M. T. Özsu & P. Valduriez Ch.6/40
Reduction for Hybrid Fragmentation
• Combine the rules already specified:
➡ Remove empty relations generated by contradicting selections on horizontal
fragments;
➡ Distribute joins over unions in order to isolate and remove useless joins.