Download presentation
Presentation is loading. Please wait.
1
Cost-Based Plan Selection Chapter 16 Section 5 ID: 213
2
Outline Cost-base plan selection involves: Cost estimation Statistics computation Query plan optimization using computed costs: Heuristics approach Enumerating and selecting methods
3
Cost Estimation Book keeping of counts to estimate costs: T(R), V(R,a), B(R), histogram Types of Histogram: Equal-width: divide value range by fixed width w and keep counts of each width Equal-height: similar as width but keep aggregated counts Most-frequent-values: values and number of occurences
4
Computation of Statistics Statistics are fault-tolerant, good for use in estimates; e.g. small error does not significantly change out come. Inspect the distribution of values across records in relation Collection on entire relation is expensive; however, can be computed using smaller sample size
5
Reducing Cost by Heuristics Applies for logical query plan Estimate cost before and after a transformation Only choose/apply transformation when cost estimations show beneficial Example: Deferring duplicate elimination is better
6
Reducing Cost: Example Plan a: 100+50+1000 = 1150 Plan b: 100+1000 = 1100
7
Enumerating Physical Plans Baseline approach (exhaustive): consider all combinations, pick the smallest cost plan Other approaches categorized into: Top-down: compute cost from root, take the best Bottom-up: compute cost for all combinations for a sub-expression, select the best, move up until root evaluated
8
List of Other Approaches Heuristic selection Branch-and-bound plan enumeration: keep record of best cost, skip to next plan if current plan exceed best known cost Hill climbing Dynamic programming (PP): keep least cost of each sub-expression; work bottom-up Selinger-style optimization: improved version of DP; keep others beneficial plans besides least cost plans
9
The End Thank you! Q&A Contact:
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.