QueryOptimization Flashcards
What is query optimization?
The process of selecting the most efficient query-evaluation plan from possible strategies for processing a query
What are the two main aspects of optimization?
1) Finding equivalent but more efficient relational-algebra expressions 2) Selecting detailed processing strategies (algorithms, indices)
What are the three steps to generate query-evaluation plans?
1) Generate logically equivalent expressions 2) Annotate expressions to create alternative plans 3) Estimate costs and choose least costly plan
What three factors is plan cost estimation based on?
1) Statistics about relations 2) Statistics estimation for intermediate results 3) Cost formulas for algorithms
What makes two relational-algebra expressions equivalent?
They generate the same set of tuples on every legal database instance
How can join operations be optimized?
By carefully choosing the join order to reduce size of temporary results
What is a cost-based optimizer?
A system that explores all equivalent query-evaluation plans and chooses the one with least estimated cost
What are two common types of histograms used in databases?
Equi-width histograms and equi-depth histograms
When are database statistics typically updated?
During periods of light system load
What is a key heuristic rule for query optimization?
Perform selections as early as possible to reduce number of tuples