0% found this document useful (0 votes)
26 views3 pages

Query Processing

Uploaded by

Niroj Thapa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views3 pages

Query Processing

Uploaded by

Niroj Thapa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Query Processing

Query Processing is the activity performed in extracting data from the database. In
query processing, it takes various steps for fetching the data from the database.

Steps involved in query processing

1) Parsing and Translation


a. A given human readable query is translated into its internal form.
b. The parser checks the syntax and also verifies the relation names in the query
matches relations in database
c. The system construct a parse tree representation of the query.
d. The parse-tree is used to form a relational algebra expression

2) Query Optimization
a) The relational algebra expression can be evaluated by many methods or ways.
b) Optimization involves the best way to evaluate the query with lowest cost.
c) Cost is estimated using statistical information from the database catalog.

3) Query Evaluation
The evaluation engine takes a selected query evaluation plan, execute the plan and
finally provides output to the users.

Query Cost Estimation

Query Cost is a cost in which the enhancer considers what amount of time a query
will require (comparative with absolute clump time). Then the analyzer attempts to
pick the most ideal query plan by taking a glance at the inquiry and insights of the
information, attempting a few execution designs and choosing the most in-
expensive of them.

The cost estimation of a query evaluation plan is calculated in term of various


resource that include

 Number of disk accesses


 Execution time taken by CPU to execute a query
 Number of tables row
 Communication costs
Query Operation, Operator TREE

A Query Tree is a data structure used for the internal representation of a query in
RDBMS. It is also known as the Query Evaluation/Execution Tree. The leaf nodes of
the query tree represent the relations, and the internal nodes are the relational
algebra operators like SELECT (σ), JOIN (⋈), etc. The root node gives the output of
the query on execution.

Example:
Consider a relational algebra expression –
πp (R ⋈ R.P = S.P S)
Step 1: Write the relations you want to execute as the tree’s Leaf nodes. Here R
and S are the relations.

Two Relations R and S

Step 2: Add the condition (here R.P = S.P) with the relational algebra operator as
an internal node (or parent node of these two leaf nodes).

JOIN R and S where R.P = S.P

Step 3: Now add the root node that on execution gives the output of the query.

Execution Output
Evaluation of Expressions

For evaluating an expression that carries multiple operations in it, we can perform
the computation of each operation one by one. There are two methods for
evaluating an expression carrying multiple operations:

Materialization:

In this method, the given expression evaluates one relational operation at a time.
Also, each operation is evaluated in an appropriate sequence or order. After
evaluating all the operations, the outputs are materialized in a temporary relation for
their subsequent uses. It leads the materialization method to a disadvantage. The
disadvantage is that it needs to construct those temporary relations for materializing
the results of the evaluated operations, respectively. These temporary relations are
written on the disks unless they are small in size.

Pipelining

Pipelining is an alternate method or approach to the materialization method. In


pipelining, it enables us to evaluate each relational operation of the expression
simultaneously in a pipeline. In this approach, after evaluating one operation, its
output is passed on to the next operation, and the chain continues till all the relational
operations are evaluated thoroughly. Thus, there is no requirement of storing a
temporary relation in pipelining.

Query Optimization

The process of selecting an efficient plan for processing a query is known as query
optimization. Query Optimization is used to access and modify the database in the
most efficient way possible. It is formally described as the process of transforming
a query into an equivalent form.

Performance Tuning

Database performance tuning refers to the various ways database administrators can
ensure databases are running as efficiently as possible. Typically, this refers to tuning
SQL Server or Oracle queries for enhanced performance. The goal of database tuning
is to reconfigure the operating systems according to how they’re best used, including
deploying clusters, and working toward optimal database performance to support
system function and end-user experience. Database performance tuning works
initially by using historical data to establish a performance baseline. Baseline data
should include:  Application statistics (transaction volumes, response time)
 Database statistics
 Operating system statistics
 Disk I/O statistics
 Network statistics

You might also like