Open In App

SQL | Query Processing

Last Updated : 14 Aug, 2018
Improve
Improve
Like Article
Like
Save
Share
Report

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):

    1. Syntax check – concludes SQL syntactic validity. Example:
      SELECT * FORM employee 

      Here error of wrong spelling of FROM is given by this check.

    2. Semantic check – determines whether the statement is meaningful or not. Example: query contains a tablename which does not exist is checked by this check.
    3. 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.

  • 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.


My Personal Notes arrow_drop_up

Next Article

Similar Reads

Difference between Structured Query Language (SQL) and Transact-SQL (T-SQL)
Structured Query Language (SQL): Structured Query Language (SQL) has a specific design motive for defining, accessing and changement of data. It is considered as non-procedural, In that case the important elements and its results are first specified without taking care of the how they are computed. It is implemented over the database which is drive
2 min read
Online Transaction Processing (OLTP) and Online Analytic Processing (OLAP)
Online Transaction Processing (OLTP): OLTP databases are meant to be used to do many small transactions, and usually serve as a "single source of storage". An example of OLTP system is online movie ticket booking website. Suppose two persons at the same time wants to book the same seat for the same movie for same movie timing then in this case whoe
5 min read
SQL Query to Add Email Validation Using Only One Query
In this article let us see how can we check for the validation of mails in the student database using MSSQL as the database server. For example, if the email is like abcdedfABCDEF...0123456@gmail.com this is the valid form of an email if it is other than this then that is said to Invalid. So, now we will discuss this concept in detail step-by-step:
2 min read
SQL Query to Check if Date is Greater Than Today in SQL
In this article, we will see the SQL query to check if DATE is greater than today's date by comparing date with today's date using the GETDATE() function. This function in SQL Server is used to return the present date and time of the database system in a ‘YYYY-MM-DD hh:mm: ss. mmm’ pattern. Features: This function is used to find the present date a
2 min read
SQL Query to Add a New Column After an Existing Column in SQL
Structured Query Language or SQL is a standard Database language that is used to create, maintain and retrieve data from relational databases like MySQL, Oracle, SQL Server, Postgres, etc. In Microsoft SQL Server, we can change the order of the columns and can add a new column by using ALTER command. ALTER TABLE is used to add, delete/drop or modif
3 min read
SQL Query to Convert Rows to Columns in SQL Server
In this article we will see, how to convert Rows to Column in SQL Server. In a table where many columns have the have same data for many entries in the table, it is advisable to convert the rows to column. This will help to reduce the table and make the table more readable. For example, Suppose we have a table given below: NAMECOLLEGEROLL NUMBERSUB
2 min read
Query Processing in Distributed DBMS
Query processing in a distributed database management system requires the transmission of data between the computers in a network. A distribution strategy for a query is the ordering of data transmissions and local data processing in a database system. Generally, a query in Distributed DBMS requires data from multiple sites, and this need for data
5 min read
Pipeline in Query Processing in DBMS
Database system processing in a satisfactory manner encompasses providing fast responses to data retrieval and manipulation tasks, with two of the keywords being performance and responsiveness. A concept that acts as the foundational element in improving batch processing performance is called "pipeline." In this article, the network of rungs or pip
5 min read
Selection Operation in Query Processing in DBMS
Regarding query processing, the term "selection" operation denotes fetching particular rows from a database table that fulfill some given condition or conditions. Why is this important? Because databases manage vast volumes of information, users must be able to narrow down their searches based on different parameters. The next few lines explain how
9 min read
Configure SQL Jobs in SQL Server using T-SQL
In this article, we will learn how to configure SQL jobs in SQL Server using T-SQL. Also, we will discuss the parameters of SQL jobs in SQL Server using T-SQL in detail. Let's discuss it one by one. Introduction :SQL Server Agent is a component used for database task automation. For Example, If we need to perform index maintenance on Production ser
7 min read
Article Tags :
three90RightbarBannerImg