Query Processing
Query Processing
ABHIJEETRAMANI,MobileNo.9893132000
WHAT IS QUERY PROCESSING? EXPLAIN STAGES
IN QUERY PROCESSING?
Query processing refers to the range of activities
involved in extracting data from a database.
Basic steps involved in Query processing are:
Parsing and Translation
Optimization
Evaluation.
Consider the figure shown below,
Page1
DBMS
ABHIJEETRAMANI,MobileNo.9893132000
Page2
Efficient Query Processing is very important for the
operations of database.
Query processing depends on number of factors, not
everything under the control of DBMS (fragmented memory
as discussed above is not under DBMS control).
The explanation of the above figure is discussed below,
Every SQL query is a high level language. This
language cannot be understood by the system.
So initially SQL query which is an input to the
PARSER/COMPILER block is been converted
to machine language.
The scanning of query is done by the compiler
through the lexical analyzer.
Here the SQL query is read character by
character by character.
Each query which is an input is actually a string.
So, while reading the query a TOKEN STRING
(keywords, constants, variables etc) is
recognized and sends to PARSER.
The PARSER passes the token string and checks
the syntax. If there is no syntax error then it
means that the PARSER has accepted that
TOKEN STRING. Now the validation is done.
After validation this TOKEN STRING is passed
to the RELATIONAL-ALGEBRA BLOCK.
Here the TOKEN STRING is converted Into the
INTERMEDIATE QUERY REPRESENTATION.THIS
REPRESENTATION IS ACTUALLY IN
RELATIONAL ALGEBRA AND
EQUIVALENT TO INPUT QUERY STRING.
This intermediate query representation is also
known as LOGICAL QUERY PLAN TREE.
DBMS
ABHIJEETRAMANI,MobileNo.9893132000
Page3
This intermediate query is passed to the
optimizer.
Here various optimizing techniques are applied
on this intermediate query and the query and
few operations is written again.(to get better
query)
The normally used optimizing techniques are
heuristic technique and cost based technique.
After this the query execution plan is generated.
This is also known as physical query plan tree.
This generated query is not in machine language.
But it is in separate language; normally in
internal query with there own constraints and
algebra. This is done to interact with the internal
structure such as disk, files etc
After this the query is given to query code
generator. Here the generator either executes the
query or converts it into machine executable
form. This query is linked with the evaluation
engine and the database which executes the
query and gives the output.