This presentation is made with many efforts and I believe that it will be proven as good presentation to clear the basic of query processing and optimization under the DBMS subject. The topics covered in this presentation are the basic fundamentals of the topic as suggested.
2. What is Query Processing?
It is a 3 step process that transforms a high level query
(sql) into an equivalent and more efficient lower-level
query (of relational algebra).
4. Parser & Translator
Query
Parser
&
Translator
Parser: Checks the syntax and verifies the relation.
Translator: Translates the query into an equivalent
relational algebra.
Example:
SQL> select name from customer;
RA:=∏name(customer)
5. Relational Algebra
Query
Parser
&
Translator
Relational
Algebra
It is the query converted in algebraic form from pl/ sql by
translator.
Example:
SQL>SELECT ENAME FROM EMP,ASG WHERE
EMP.ENO=ASG.ENO AND DUR>37;
RA:1) ΠENAME(σDUR>37∧EMP.ENO=ASG.ENO(EMP × ASG))
2) ΠENAME(EMP ENO (σDUR>37(ASG)))
6. Optimizer
Query
Parser
&
Translator
Relational
Algebra
Optimizer
It will select the query which has low cost.
Example:
1) ΠENAME(σDUR>37∧EMP.ENO=ASG.ENO(EMP × ASG))
2) ΠENAME(EMP ENO (σDUR>37(ASG)))
Optimizer will select Expression2 as it avoids
the expensive and large intermediate
Cartesian product, and therefore typically is
better.
7. Comparison of two relational queries
ΠENAME(σDUR>37∧EMP.ENO=ASG.ENO
(EMP × ASG))
ΠENAME(EMP ENO(σDUR>37(ASG)))
EMP x ASG
Temp as
EMP.ENO=ASG.ENO
ΠENAME
ENO(σDUR>37(ASG)
EMP ENO
ΠENAME
σDUR>37 ∧temp
10. EVALUATION & DATA
The evaluation
engine takes
the evaluation
plan as
condition and
applies it on
the data.
Query
Parser
&
Translator
Relational
Algebra
Optimizer
Statistical
Data
Evaluation
Plan
Evaluation
The information on
which the query has
to be performed is
called data.Data
12. Diagram of Query Processing
Query
Parser
&
Translator
Relational
Algebra
Optimizer
Statistical
Data
Evaluation
Plan
EvaluationOutput
Data
13. Measures of Query Cost
The cost of query evaluation can be measured in
terms of different resources, including
disk accesses
CPU time to execute a query in a distributed or
parallel database system
the cost of communication.
14. Materialization
In materialization approach, output of every single operation
is saved in temporary relation for the subsequent use.
It starts from the lowest-level operations in the expression.
Ex: Πcustomer(σbalance<2500(account) customer)
Πcustomer
σbalance<2500 customer
account
15. Pipelining
In pipelining approach, output of every single operation is not
necessary to save in temporary relation for the subsequent
use.
In this the operations take place simultaneously or in
background
It starts from the lowest-level operations in the expression.
Ex: Πcustomer(σbalance<2500(account) customer)
Πcustomer
σbalance<2500 customer
account
16. Query Optimization
It is the process of selecting the most efficient query-
evaluation plan from among the many strategies usually
possible for processing a given query, especially if the query is
complex.