Query Processing includes translations on high level Queries into low level expressions that can be used at physical level of file system, query optimization and actual execution of query to get the actual result.
Block Diagram of Query Processing is as:

Detailed Diagram is drawn as:

It is done in the following steps:
- Step-1:
Parser: During parse call, the database performs the following checks- Syntax check, Semantic check and Shared pool check, after converting the query into relational algebra.Parser performs the following checks as (refer detailed diagram):
- Syntax check – concludes SQL syntactic validity. Example:
SELECT * FORM employee
Here error of wrong spelling of FROM is given by this check.
- Semantic check – determines whether the statement is meaningful or not. Example: query contains a tablename which does not exist is checked by this check.
- Shared Pool check – Every query possess a hash code during its execution. So, this check determines existence of written hash code in shared pool if code exists in shared pool then database will not take additional steps for optimization and execution.
Hard Parse and Soft Parse –
If there is a fresh query and its hash code does not exist in shared pool then that query has to pass through from the additional steps known as hard parsing otherwise if hash code exists then query does not passes through additional steps. It just passes directly to execution engine (refer detailed diagram). This is known as soft parsing.
Hard Parse includes following steps – Optimizer and Row source generation. - Syntax check – concludes SQL syntactic validity. Example:
- Step-2:
Optimizer: During optimization stage, database must perform a hard parse atleast for one unique DML statement and perform optimization during this parse. This database never optimizes DDL unless it includes a DML component such as subquery that require optimization.It is a process in which multiple query execution plan for satisfying a query are examined and most efficient query plan is satisfied for execution.
Database catalog stores the execution plans and then optimizer passes the lowest cost plan for execution.Row Source Generation –
The Row Source Generation is a software that receives a optimal execution plan from the optimizer and produces an iterative execution plan that is usable by the rest of the database. the iterative plan is the binary program that when executes by the sql engine produces the result set. - Step-3:
Execution Engine: Finally runs the query and display the required result.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
Recommended Posts:
- Difference between Structured Query Language (SQL) and Transact-SQL (T-SQL)
- Online Transaction Processing (OLTP) and Online Analytic Processing (OLAP)
- SQL | SELECT Query
- SQL query to find second highest salary?
- Structured Query Language (SQL)
- What are the Best Ways to Write a SQL Query?
- Features of Structured Query Language (SQL)
- SQL query using COUNT and HAVING clause
- SQL Query Complexity
- SQL query to find unique column values from table
- SQL | Query to select NAME from table using different options
- SQL | Procedures in PL/SQL
- SQL | Difference between functions and stored procedures in PL/SQL
- Difference between T-SQL and PL-SQL
- Difference between SQL and T-SQL
- On Line Transaction Processing (OLTP) System in DBMS
- Difference between Data Warehousing and Online transaction processing (OLTP)
- File Processing System (FPS)
- Query Optimization in Relational Algebra
- PHP | MySQL UPDATE Query
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

