Query Processing
Query Processing
2. Optimization
3. Evaluation
As query processing includes certain activities for data retrieval. Initially, the
given user queries get translated in high-level database languages such as
SQL. It gets translated into expressions that can be further used at the
physical level of the fle system. After this, the actual evaluation of the
queries and a variety of query -optimizing transformations and takes place.
Thus before processing a query, a computer system needs to translate the
query into a human-readable and understandable language. Consequently,
SQL or Structured Query Language is the best suitable choice for humans.
But, it is not perfectly suitable for the internal representation of the query to
the system. Relational algebra is well suited for the internal representation of
a query. The translation process in query processing is similar to the parser
of a query. When a user executes any query, for generating the internal form
of the query, the parser in the system checks the syntax of the query,
verifes the name of the relation in the database, the tuple, and fnally the
required attribute value. The parser creates a tree of the query, known as
'parse-tree.' Further, translate it into the form of relational algebra. With this,
it evenly replaces all the use of the views when used in the query.
Thus, we can understand the working of a query processing in the below-
described diagram:
Suppose a user executes a query. As we have learned that there are various
methods of extracting the data from the database. In SQL, a user wants to
fetch the records of the employees whose salary is greater than or equal to
10000. For doing this, the following query is undertaken:
Evaluation
o The annotations in the evaluation plan may refer to the algorithms to be used
for the particular index or the specifc operations.
Optimization
o The cost of the query evaluation can vary for diferent types of queries.
Although the system is responsible for constructing the evaluation plan, the
user does need not to write their query efciently.
o Usually, a database system generates an efcient query evaluation plan,
which minimizes its cost. This type of task performed by the database system
and is known as Query Optimization.
o For optimizing a query, the query optimizer should have an estimated cost
analysis of each operation. It is because the overall operation cost depends
on the memory allocations to several operations, execution costs, and so on.
Finally, after selecting an evaluation plan, the system evaluates the query
and produces the output of the query.