Vu Lec 30
Vu Lec 30
Management Systems
Lecture 30
In the previous lecture
• Locking based CC
• Timestamp ordering
based CC
• Concluded TM.
In this Lecture
• Basic Concepts of Query
Optimization
• QP in centralized and
Distributed DBs.
Introduction
• SQL one of the success
factors of RDBMS
• Query processor
transforms complex
queries into concise and
simple ones
• Query processing is
critical performance
issue
• QP a complex
problem specially in
DDBS environment
• Main function of QP is to
transform an SQL query
into equivalent relational
algebra one (low level
language)
• Transformation must
achieve correctness and
efficiency
• Correctness is
straightforward since
rules exist
• An SQL query can
have many equivalents
in R Algebra
• Considering the tables
• EMP(eNo, eName, title)
• ASG(eNo, pNo, resp, dur)
• PROJ(pNo, pName,
budget, loc)
• Query: Get the names of
employees who are
managing a project
• SELECT eName
FROM EMP, ASG
WHERE EMP.eNo =
ASG.eNo
AND resp = ‘Manager’
eName(resp=‘Manager’ ^ EMP.eNo =
ASG.eNo) (EMPxASG)
eName(EMP ⋈ (resp=‘Manager’
(ASG)))
• Obviously second one needs
less computing resources
since avoids Cartesian product
• Centralized QP is to
choose best query
execution plan
• Distributed is more
complex; it also involves
the selection of site to
execute query
• Same query in DDBS
• Suppose EMP and ASG are
HF as
• EMP1 = eNo ≤ ‘E3’ (EMP)
• EMP2 = eNo > ‘E3’ (EMP)
• ASG1 = eNo ≤ ‘E3’ (ASG)
• ASG2 = eNo > ‘E3’ (ASG)
• Further suppose these
fragments are stored
at site 1, 2, 3 and 4
and result at site 5
result = EMP1’ U EMP2’ Site 5
EMP1’ EMP2’
Site 3 Site 4
EMP1’=EMP1 ⋈(ASG ’) 1
EMP2’=EMP2 ⋈(ASG ’)2
ASG1’ ASG2’
Site 1 Site 2
ASC1’=resp = ‘Manager(ASG1) ASC2’=resp = ‘Manager(ASG2)
result = (EMP1 U EMP2) ⋈ eNo
resp = ‘Manager’ (ASG1 U ASG2)
ASG1 ASG2 EMP1 EMP2
Optimized
Local Query