3. Introduction
• Query
A query is a request for information from
a database.
• Query Processing
It is a translation of high-level queries into low level
expressions . It is a step wise process that can be
used at the physical level of the file system.
4. • Query Optimization
It is a process in which multiple query-execution
plans for satisfying a query are examined and the
most efficient query plan is identified
GOAL
The goal of query optimization is to reduce the
system resources required to fulfill a query, and
ultimately provide the user with the correct result
set faster.
6. • Parser: During parse call, the database
performs the following checks- Syntax check,
Semantic check and Shared pool check.
• Query Optimizer: attempts to determine the
most efficient way to execute a given query by
considering the possible query plans.
• Execution Engine: Finally runs the query and
display the required result.
7. Query Block
• It is the basic unit of SQL that operates on tables
on the results of other queries by performing
join, grouping, projection, or selection
operations. The result of a query block is a table
that is known as a derived table.
8.
9.
10. Query Optimization Criteria
Optimization Criteria
Reduce total execution time of the query:
• Minimize the sum of the execution times of all
individual operations
• Reduce the number of disk access
Reduce response time of the query:
• Maximize parallel operations
11. Query Optimization Issues
Query Rewriting:
• Transformation from one SQL query to another
one using semantic properties.
Selecting query execution plan:
• Done on single query block.
Cost estimation:
• To compare between plans we need to estimate
their cost using statistics on database.
12. Advantages
1. Faster processing of query
2. Lesser cost per query
3. High performance of the system
4. Lesser stress on database
5. Efficient usage of database engine
6. Lesser memory is consumed