Distributed Database Management Systems: Lecture 34. The main topics covered in this chapter include: query optimization; centralized QO; best access path; join processing; QO in distributed environment; single relation queries: executed according to the best access path;...
Trang 1Distributed Database Management Systems
Lecture 34
Trang 2In the previous lecture
• Concluded Data Localization
• Query Optimization
– Components: Search space, cost
model, search strategy
– SS consists of eq query trees
– SSts could be static, dynamic or
randomized
– Cost model sees response and total
times…
Trang 3–Database statistics are used to
evaluate size of iterm Tables
–Selectivity factor, card, size are
some major figures
Trang 5• Queries involving Joins
in three steps
Trang 61 Determine the possible
ordering of
joins-2 Determine the cost of
each ordering
3 Choose the join ordering
with minimal cost
Trang 7• Cost model assigns
Trang 8statistics-• Two major steps in
Optimization Algorithm
– Best access path for
individual relation with pred
– The best join ordering; two
possibilities.
Trang 11• Example: Select eName
From EMP, ASG, PROJ Where
EMP.eNo = ASG.eNo & PROJ.pNo = ASG.pNo & pName = ‘CAD/CAM’
Trang 12• EMP has an index on eNo
• ASG has an index on pNo
• PROJ has an index on
pNo and an index on
Trang 131- Choose the best access paths to each relation
• EMP: sequential scan (no
Trang 142- Determine the best join ordering
–Total 3! orderings are
possible
–Rather than computing for
all, some of them are pruned
–Shown in the tree, next page
Trang 15(ASG EMP ⋈ ) PROJ ⋈ (PROJ⋈ASG)⋈E
MP
Trang 16Join Ordering in
Fragmented Queries
Trang 18Join Ordering
• Two relations: move the
smaller relation to the
Trang 19• More than 2 relations
– Calculate all possible
costs
– Requires to compute size
of intermediate tables
– Difficult! Lets see why
Trang 20• Strategy 1:
EMPsite2, site2 computes EMP’= EMP ⋈ ASGsite3 computes EMP’ ⋈ PROJ
Trang 21• Strategy 2:
ASGsite1, site1 computes EMP’= EMP ⋈ ASGsite3 computes EMP’ ⋈ PROJ
Trang 22• Strategy 3:
ASGsite3, site3 computes ASG’= PROJ ⋈ ASGsite1 computes EMP ⋈ ASG’
Trang 23• Strategy 4:
PROJsite2, site2 computes PROJ’= PROJ ⋈ ASGsite1 computes EMP ⋈ PROJ’
Trang 24• Strategy 5:
EMP, PROJsite2, site2
computes PROJ ⋈ ASG ⋈
Trang 25Which one to Choose
• We need to know
–Size of operand tables
–Estimate interm tables’ size
• Computing all possibilities
could be lengthy
• Heuristic: Consider only
the size of
Trang 26tables-Thanks