This presentation discusses the following topics:
Introduction to Query Processing
Need for Query processing
Architecture of Query Processing
Query Processing Steps
Phases in a typical query processing
Represented in relational structures
Translating SQL Queries into Relational Algebra
Query Optimization
Importance of Query Optimization
Actions of Query Optimization
1. Department of Information Technology 1Data base Technologies (ITB4201)
Query Processing
Dr. C.V. Suresh Babu
Professor
Department of IT
Hindustan Institute of Science & Technology
2. Department of Information Technology 2Data base Technologies (ITB4201)
Action Plan
• Introduction to Query Processing
• Need for Query processing
• Architecture of Query Processing
• Query Processing Steps
• Phases in a typical query processing
• Represented in relational structures
• Translating SQL Queries into Relational Algebra
• Query Optimization
• Importance of Query Optimization
• Actions of Query Optimization
• Quiz
3. Department of Information Technology 3Data base Technologies (ITB4201)
Introduction to Query Processing
• Query Processing is a translation of high-level queries into low-level expression.
• It is a step wise process that can be used at the physical level of the file system,
query optimization and actual execution of the query to get the result.
• It requires the basic concepts of relational algebra and file structure.
• It refers to the range of activities that are involved in extracting data from the
database.
• It includes translation of queries in high-level database languages into
expressions that can be implemented at the physical level of the file system.
• In query processing, we will actually understand how these queries are
processed and how they are optimized.
4. Department of Information Technology 4Data base Technologies (ITB4201)
Need for Query processing
• Is to transform a query in a high level declarative language (such as SQL) into a
correct and efficient execution strategy. It includes query decomposition
(analysis, conjunctive and disjunctive normalization and semantic analysis),
query optimization and query evaluation (execution).
• Query processing refers to the process to answer a query to a database or an
information system, which usually involves interpreting the query, searching
through the space storing data, and retrieving the results satisfying the query.
• Extracting information from a large amount of data without actually changing
the underlying database where the data are organized.
• The process of how queries are processed and optimized within the database
management system. It consists of a series of steps that take the query as input
and produce its result as output
4
5. Department of Information Technology 5Data base Technologies (ITB4201)
Architecture of Query Processing
• The first step is to transform the query into a
standard form.
• A query is translated into SQL and into a relational
algebraic expression. During this process, Parser
checks the syntax and verifies the relations and
the attributes which are used in the query.
• The second step is Query Optimizer. In this, it
transforms the query into equivalent expressions
that are more efficient to execute.
• The third step is Query evaluation. It executes the
above query execution plan and returns the
result.
6. Department of Information Technology 6Data base Technologies (ITB4201)
Query Processing Steps
6
It is the step by step process of breaking the high level language into low level language which machine can understand
and perform the requested action for user. Query processor in the DBMS performs this task.
7. Department of Information Technology 7Data base Technologies (ITB4201)
Phases in a typical query processing
• Parsing and Translation
• Query Optimization
• Evaluation or query code generation
• Execution in DB’s runtime processor
7
8. Department of Information Technology 8Data base Technologies (ITB4201)
Represented in relational structures
∏ STD_ID, STD_NAME, ADDRESS, DOB (σ CLASS_NAME = ‘DESIGN_01’ (STUDENT ∞CLASS))
Or
σ CLASS_NAME = ‘DESIGN_01’ (∏ STD_ID, STD_NAME, ADDRESS, DOB (STUDENT ∞CLASS))
9. Department of Information Technology 9Data base Technologies (ITB4201)
Translating SQL Queries into Relational Algebra
• SELECT Ename FROM Employee WHERE Salary > 5000;
Translated into Relational Algebra Expression
σ Salary > 5000 (π Ename (Employee))
OR
π Ename (σ Salary > 5000 (Employee))
10. Department of Information Technology 10Data base Technologies (ITB4201)
• A sequence of primitive operations that can be
used to evaluate a query is a Query Execution
Plan or Query Evaluation Plan.
• The diagram indicates that the query execution
engine takes a query execution plan and returns
the answers to the query.
• Query Execution Plan minimizes the cost of
query evaluation
Translating SQL Queries into Relational Algebra
12. Department of Information Technology 12Data base Technologies (ITB4201)
Introduction to Query Optimization
• Query optimization is a difficult part of the query processing.
• It determines the efficient way to execute a query with different possible query plans.
• It cannot be accessed directly by users once the queries are submitted to the database
server or parsed by the parser.
• A query is passed to the query optimizer where optimization occurs.
• Main aim of Query Optimization is to minimize the cost function,
I/O Cost + CPU Cost + Communication Cost
• It defines how an RDBMS can improve the performance of the query by re-ordering the
operations.
• It is the process of selecting the most efficient query evaluation plan from among various
strategies if the query is complex.
• It computes the same result as per the given expression, but it is a least costly way of
generating result.
12
13. Department of Information Technology 13Data base Technologies (ITB4201)
Importance of Query Optimization
• Query optimization provides faster query processing.
• It requires less cost per query.
• It gives less stress to the database.
• It provides high performance of the system.
• It consumes less memory.
14. Department of Information Technology 14Data base Technologies (ITB4201)
Some Actions of Query Optimization
• Reordering joins.
• Changing the positions of projects and selects.
• Changing the access structures used to read data.
15. Department of Information Technology 15Data base Technologies (ITB4201)
Test Yourself
1. Which is one of the major important components of the relational database:
a. Query execution
b. Query process
c. Query optimizer
d. Query transaction
2. Which in the database which is a software component in the RDBMS that carries out analysis of SQL statement for finding the best
way for its execution:
a. Query execution
b. Query process
c. Query optimizer
d. Query transaction
3. Which can be defined as the method in which the selected plan is executed at the query optimization stages:
a. Query execution
b. Query process
c. Query optimizer
d. Query transaction
4. Which refers to technique of maintaining, managing and manipulating data store within the computer system by using SQL queries:
a. Query execution
b. Query processing
c. Query optimizer
d. Query transaction
5. Which is the method of processing the plan selected throughout query optimization:
a. Query execution
b. Query process
c. Query optimizer
d. Query transaction
16. Department of Information Technology 16Data base Technologies (ITB4201)
Answers
1. Which is one of the major important components of the relational database:
a. Query execution
b. Query process
c. Query optimizer
d. Query transaction
2. Which in the database which is a software component in the RDBMS that carries out analysis of SQL statement for finding the best
way for its execution:
a. Query execution
b. Query process
c. Query optimizer
d. Query transaction
3. Which can be defined as the method in which the selected plan is executed at the query optimization stages:
a. Query execution
b. Query process
c. Query optimizer
d. Query transaction
4. Which refers to technique of maintaining, managing and manipulating data store within the computer system by using SQL queries:
a. Query execution
b. Query processing
c. Query optimizer
d. Query transaction
5. Which is the method of processing the plan selected throughout query optimization:
a. Query execution
b. Query process
c. Query optimizer
d. Query transaction