Query Processing
Query Processing
Query Processing
- In the example above, CLASS_ID of DESIGN_01 is passed to the STUDENT table to get the student details.
- In this method no extra cost of writing into temporary tables. It has only cost of evaluation of individual
queries; hence it has better performance than materialization.
Types of Pipelining
1. Demand Driven or Lazy evaluation
- In this method, the result of lower level queries are not passed to the higher level automatically.
- It will be passed to higher level only when it is requested by the higher level.
- In this method, it retains the result value and state with it and it will be transferred to the next level only when it is
requested.
- In our example above, CLASS_ID for DESIGN_01 will be retrieved, but it will not be passed to STUDENT query only when it is
requested. Once it gets the request, it is passed to student query and that query will be processed.
2. Producer Driven or Eager Pipelining
- In this method, the lower level queries eagerly pass the results to higher level queries.
- It does not wait for the higher level queries to request for the results.
- In this method, lower level query creates a buffer to store the results and the higher level queries pulls the results for its use.
- If the buffer is full, then the lower level query waits for the higher level query to empty it. Hence it is also called as PULL and
PUSH pipelining.
Query Optimization in DBMS
- We have seen so far how a query can be processed based on indexes
and joins, and how they can be transformed into relational expressions.
- The query optimizer uses these two techniques to determine which
process or expression to consider for evaluating the query.
-Example : Relation schema:
instructor (ID , name , dept_name , salary)
teaches (ID , course_id , sec_id , semester , year)
course (course_id , title , dept_name , credits)
- Find the names of all instructors in the music department together
with the course title of all the courses that the instructor teaches?
πname , title (σdept_name = 'Music'(instructor |X| (teaches |X| πcourse_id , title (course))))
Methods of Query Optimization