0% found this document useful (0 votes)
2 views32 pages

Query Optimization & Processing

The document discusses query optimization and processing, emphasizing the importance of efficient query execution and cost minimization. It outlines the steps involved in query processing, including parsing, evaluation, and optimization, as well as the different approaches like exhaustive search and heuristic-based optimization. Additionally, it touches on temporal and multimedia databases, highlighting their unique characteristics and applications.

Uploaded by

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

Query Optimization & Processing

The document discusses query optimization and processing, emphasizing the importance of efficient query execution and cost minimization. It outlines the steps involved in query processing, including parsing, evaluation, and optimization, as well as the different approaches like exhaustive search and heuristic-based optimization. Additionally, it touches on temporal and multimedia databases, highlighting their unique characteristics and applications.

Uploaded by

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

Query Optimization &

Processing

-Manisha Kapila
Query Optimization &
Processing
Query optimization is a difficult part of the query processing.

It determines the efficient way to execute a query with


different possible query plans.

Itcannot be accessed directly by users , once the queries


are submitted to the DB.

Main aim of query optimization is to minimize the cost


function.
-Manisha Kapila
 I/O Cost + CPU cost + Communication Cost.

 Itdefines how RDBMS can improve the performance of


the query by re-ordering the operations.

 Itis the process of selecting the most efficient query


evaluation plan from various strategies if the query is
complex.

-Manisha Kapila
 Query optimization provides faster query processing.

 It requires less cost per query.

 It gives less stress to the database.

 It provides high performance of the system.

 It consumes less memory.

-Manisha Kapila
 Query Processing includes translations on high level
Queries into low level expressions that can be used at
physical level of file system, query optimization and
actual execution of query to get the actual result.

-Manisha Kapila
-Manisha Kapila
Step 1:Parser and Translator
 During parse call, the database performs
the following checks:

 Syntax check, Semantic check and


Shared pool check, after converting the
query into relational algebra.

 Syntax Check: SELECT * FORM


Employee;
-Manisha Kapila
 Semantic Check: determines whether the
statement is meaningful or not. Example:
query contains a table name which does
not exist is checked by this check.

 Shared Pool check –Every query possess


a hash code during its execution. So, this
check determines existence of written hash
code in shared pool if code exists in shared
pool then database will not take additional
steps for optimization and execution.
-Manisha Kapila
 InSQL, a user wants to fetch the records of the
employees whose salary is greater than or equal to
10000.

 select emp_name from Employee where


salary>10000;

 Thus, to make the system understand the user


query, it needs to be translated in the form of
relational algebra. We can bring this query in the
relational algebra form as:
 σsalary>10000 (πsalary (Employee))

-Manisha Kapila
Step 2:Evaluation
 Forthis, with addition to the relational
algebra translation, it is required to
annotate the translated relational algebra
expression with the instructions used for
specifying and evaluating each operation.

 Thus,after translating the user query, the


system executes a query evaluation plan.

-Manisha Kapila
Query Evaluation Plan:
 In order to fully evaluate a query, the system
needs to construct a query evaluation plan.

 The annotations in the evaluation plan may refer


to the algorithms to be used for the particular
index or the specific operations.

 Such relational algebra with annotations is


referred to as Evaluation Primitives. The
evaluation primitives carry the instructions
needed for the evaluation of the operation.
-Manisha Kapila
 Thus, a query evaluation plan defines a sequence
of primitive operations used for evaluating a
query. The query evaluation plan is also referred
to as the query execution plan.

A query execution engine is responsible for


generating the output of the given query. It takes
the query execution plan, executes it, and finally
makes the output for the user query.

-Manisha Kapila
Step 3:Optimization
 Although the system is responsible for constructing the
evaluation plan, the user does need not to write their query
efficiently.

 Usually,a database system generates an efficient query


evaluation plan, which minimizes its cost. This type of task
performed by the database system and is known as Query
Optimization.

A query optimizer translates a query into a sequence of


physical operators that can be directly carried out by the
query Evaluation engine .
-Manisha Kapila
Approaches to Query
Processing
 Exhaustive Search Optimization (Cost based)

 Heuristic Based Optimization(Rule based)

-Manisha Kapila
Exhaustive Search Optimization
 In these techniques, for a query, all possible query
plans are initially generated and then the best
plan is selected.

 Though these techniques provide the best


solution, it has an exponential time and space
complexity owing to the large solution space. For
example, dynamic programming technique.

-Manisha Kapila
Heuristic Based Optimization
 Heuristic based optimization uses rule-based optimization
approaches for query optimization.

 Rules:

 Perform the SELECTION process foremost in the query. This


should be the first action for any SQL table. By doing so, we
can decrease the number of records required in the query,
rather than using all the tables during the query.

-Manisha Kapila
 Perform all the projection as soon as achievable in the query.
Somewhat like a selection but this method helps in decreasing
the number of columns in the query.

 Perform the most restrictive joins and selection operations.

 What this means is that select only those sets of tables and/or
views which will result in a relatively lesser number of records
and are extremely necessary in the query. Obviously any query
will execute better when tables with few records are joined.

-Manisha Kapila
Query Tree:
A query tree is a tree data structure
representing a relational algebra expression.

 The tables of the query are represented as leaf


nodes.

 This process continues for all internal nodes


until the root node is evaluated and replaced by
the result table.

-Manisha Kapila
Query Tree:

-Manisha Kapila
Temporal Databases
A Temporal Database is a database with built-in
support for handling time sensitive data.

 Usually, databases store information only about


current state, and not about past states. For example
in a employee database if the address or salary of a
particular person changes, the database gets
updated, the old value is no longer there.

-Manisha Kapila
 However for many applications, it is important to
maintain the past or historical values and the time at
which the data was updated.

 Thatis, the knowledge of evolution is required. That is


where temporal databases are useful.

 Itstores information about the past, present and future.


Any data that is time dependent is called the temporal
data and these are stored in temporal databases.

-Manisha Kapila
 Temporal Databases store information about
states of the real world across time.

 Temporal Database is a database with built-


in support for handling data involving time. It
stores information relating to past, present
and future time of all events

-Manisha Kapila
Examples of Temporal Databases
 Healthcare Systems: Doctors need the
patients’ health history for proper diagnosis.
Information like the time a vaccination was given
or the exact time when fever goes high etc.

 Insurance Systems: Information about claims,


accident history, time when policies are in effect
needs to be maintained.

 Reservation Systems: Date and time of all


-Manisha Kapila

reservations is important.
Temporal Aspects
 Thereare two different aspects of time in
temporal databases.

 Valid Time: Time period during which a fact is


true in real world, provided to the system.

 Transaction Time: Time period during which a


fact is stored in the database, based on
transaction serialization order and is the
timestamp generated automatically by the
system.
-Manisha Kapila
Multimedia Databases
 Multimedia database is the collection of
interrelated multimedia data that includes
text, graphics (sketches, drawings),
images, animations, video, audio etc and
have vast amounts of multisource
multimedia data.

 The framework that manages different


types of multimedia data which can be
stored, delivered and utilized in different
ways is known as multimedia database
management system.
-Manisha Kapila
The multimedia database can be classified into three
types.

 Static media

 Dynamic media

 Dimensional media

-Manisha Kapila
Contents of the Multimedia Databases

 Media data: It is the actual data which represents an object.

 Media format data: The information such as resolution,


sampling rate, encoding system, etc. about the format of the
media data under consideration after is undergoes acquisition,
processing, and encoding is the media format data.

-Manisha Kapila
 Media keyword data: Media keyword data are the keyword
description related to the generation of data. This data is also known as
content descriptive data. Examples of content descriptive data are
place, time, date of recording.

 Media feature data: Media feature data contains data which is


content dependent such as kind of texture, distribution of, and the
different shapes present in the data.

-Manisha Kapila
Types of Multimedia Applications:

 Repository applications – A Large amount of


multimedia data as well as meta-data(Media
format date, Media keyword data, Media
feature data) that is stored for retrieval
purpose, e.g., Repository of satellite images,
engineering drawings, radiology scanned
pictures.

-Manisha Kapila
 Presentation applications – They involve delivery of multimedia
data subject to temporal constraint. Optimal viewing or listening
requires DBMS to deliver data at certain rate offering the quality of
service above a certain threshold. Here data is processed as it is
delivered. Example: Annotating of video and audio data, real-time
editing analysis.

 Collaborative work using multimedia information – It involves


executing a complex task by merging drawings, changing
notifications. Example: Intelligent healthcare network.

-Manisha Kapila
Multimedia Database Applications:
 Documents and record management: Industries which keep
a lot of documentation and records. Ex: Insurance claim industry.
 Education and training: Multimedia sources can be used to
create resources useful in education and training. These are
popular sources of learning in recent days. Ex: Digital libraries.
 Real-time monitoring and control: Multimedia presentation
when coupled with active database technology can be an
effective means for controlling and monitoring complex tasks.
Ex: Manufacture control

-Manisha Kapila
Challenges of Multimedia Databases
 Multimedia databases contains data in a large type of formats such
as .txt(text), .jpg(images), .mp3(audio) etc. It is difficult to convert
one type of data format to another.

 The multimedia database requires a large size as the multimedia


data is quite large and needs to be stored successfully in the
database.

 Ittakes a lot of time to process multimedia data so multimedia


database is slow.

-Manisha Kapila

You might also like