SQL Processing

 


SQL Processing

This post explains how database processes DDL statements to create objects, DML to manipulate data, and queries to retrieve data.

·       About SQL Processing

·       How Oracle DB DML

·       How Oracle DB processes DDL

About SQL Processing:-

Oracle SQL processing is the parsing, optimization, row source generation, and execution of a SQL statement. Depending on the statement, the database may omit some of these stages.

Please find the picture below in detail.

Stages of SQL Processing



Below are the select query execution flow in oracle:

  • SQL Developer or SQL*PLUS checks the syntax on client side.
  • If syntax is correct,the query is passed as a valid SQL statement and encrypted into OCI(Oracle call interface) packets and sent via LAN using TCP to the server side.
  • Once the packets reach the server the server process will rebuild the query and again perform a syntax check on server side then if syntax is correct server process will continue execution of the query.
  • The server process will go to the library cache. The library cache will keep the recently executed sql statements along with their execution plan.In the library cache the server process will search from the mru (most recently used) end to the lru (least recently used) end for a match for the sql statement. It does this by using a hash algorithm that returns a hash value. If the hash value of the query we have written matches with that of the query in library cache then server process need not generate an execution plan (soft parsing) but if no match is found then server process has to proceed with the generation of execution plan (hard parsing).Parsing is the process undertaken by oracle to generate an execution plan.
  • The first step in parsing involves performing a semantic check. This is nothing but check for the existence of the object and its structure in the database.
  • This check is done by server process in the data dictionary cache. Here server process will ask for the definition of the object, if already available within the data dictionary cache, server process will process the check. If not available then server process will retrieve the required information from the system tablespace.
  • After this in case of hard parsing the server process will approach the optimizer, who will read the sql statement and generate the execution plan of the query. the optimizer generates multiple execution plans during parsing.
  • After generation of the e-plan’s by the optimizer the sp will pick the best possible and cost effective e-plan and go to the library cache.In the library cache the server process will keep the e-plan in the library cache along with the original sql text.
  • At this point in time the parsing ends and the execution of the sql sataement will begin.Server Process will then go to the database buffer cache and checks whether the data required by the query is already available or not in the cache.
  • If available that data can be returned to the client else it brings the data from the database files.
  • If sorting and filtering is required by the query then the pga is utilized along with the temporary tablespace for performing sort run.
  • After sort run the data is returned to the client and sql*plus client will convert the given data to ascii format and display the data in a tabular format to the users.
  • Along with the temporary tablespace for performing sort run.
  • After sort run the data is returned to the client and SQL*PLUS client will convert the given data to ASCII format and display the data in tabular format to the users.

Please refer below links for some important notes.

Oracle SQL Processing 

 PLSQL Important interview questions

 

 

 

 

 

 


 

No comments:

Post a Comment

Python Installation on Windows

  1.        Download the Python latest software version from the below link. https://www.python.org/downloads/ 1.        2.    Open the ...

Tech updates