ADSI Notes - Diogo Lopes

Search

Search IconIcon to open search

Lecture 5 - Query Optimization

Last updated Mar 17, 2023

Slides

# Query Optimization

# Evaluating a given query

Query optimization is finding the optimal execution plan

# Equivalence Rules

Associative Rules in Joins can be useful to maintain order or use some index

See examples on slides

Performing the selection as early as possible reduces the size of the relation to be joined. Performing the projection as early as possible reduces the size of the relation to be joined.

# Cost-Based Optimization

Now consider finding the best join order for: (r 1 ⨝ r 2 ⨝ r 3 ⨝ r 4 ⨝ r 5)

# Heuristics in Optimization

# Concept of memoization

# Implemented as plan caching

# Materialized Views

1
2
3
4
5
create view my_students ID, name as
select student.ID, student.name
from student , takes
where student.ID = takes.ID
	and takes.course_id = 'CS 347';

# Query Optimization and Materialized Views

Rewriting queries to use materialized views:

Whether to do so depends on cost estimates for the two options The system knows which materialized views exist, so it can use them to optimize the query

Replacing a use of a materialized view:

Query optimizer should consider all above options and choose the best overall plan

# Materialized View Creation

# Statistical Information for Cost Estimation

Important for:

Lecture 4 Query Processing | Lecture 6 Transactions and concurrency