Query Processing
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.
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 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.
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.
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).
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
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