Chapter 12, 13 - Query Processing and Optimization
Chapter 12, 13 - Query Processing and Optimization
PROCESSING AND
Book Referred: Korth
6th Edition, Chapter
12 & 13
OPTIMIZATION
DATABASE
MANAGEMEN
T SYSTEMS
INTERNALS
BASIC STEPS IN QUERY
PROCESSING
1. Parsing and translation
2. Optimization
3. Evaluation
BASIC STEPS IN QUERY
PROCESSING (CONT.)
BASIC STEPS IN QUERY
PROCESSING : OPTIMIZATION
A relational algebra expression may have many equivalent
expressions
E.g.,
salary75000(salary(instructor)) is equivalent to
salary(salary75000(instructor))
Find out how to view query execution plans on your favorite database
INTRODUCTION (CONT.)
Cost difference between evaluation plans for a query can be
enormous
E.g. seconds vs. days in some cases
(r1 r2) r3
so that we compute and store a smaller temporary
relation.
JOIN ORDERING EXAMPLE
(CONT.)
Consider the expression
name, title(dept_name= “Music” (instructor) teaches)
course_id, title (course))))
Could compute teaches course_id, title (course) first, and
join result with
dept_name= “Music” (instructor)
but the result of the first join is likely to be a large relation.
Only a small fraction of the university’s instructors are likely
to be from the Music department
It is better to compute