0% found this document useful (0 votes)
83 views

Overview of Query Optimization in Oracle

The query optimizer is software that determines the most efficient execution plan for SQL statements by considering different access methods, join orders, and transformations. It chooses the lowest cost plan based on statistics about the data, where cost accounts for factors like I/O, CPU usage, and communication. The optimizer examines multiple plans involving table scans, indexes, join methods, and transformations to select the optimal plan for a given SQL statement and environment.

Uploaded by

Gowri Ilayaraja
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views

Overview of Query Optimization in Oracle

The query optimizer is software that determines the most efficient execution plan for SQL statements by considering different access methods, join orders, and transformations. It chooses the lowest cost plan based on statistics about the data, where cost accounts for factors like I/O, CPU usage, and communication. The optimizer examines multiple plans involving table scans, indexes, join methods, and transformations to select the optimal plan for a given SQL statement and environment.

Uploaded by

Gowri Ilayaraja
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Introduction to the Query Optimizer

The query optimizer is built-in database software that determines the


most efficient method for a SQL statement to access requested data.

Purpose of the Query Optimizer


 The optimizer attempts to generate the most optimal execution plan
for a SQL statement.
 The optimizer chooses the plan with the lowest cost among all
considered candidate plans.
 The optimizer uses available statistics to calculate cost.
 For a specific query in a given environment, the cost computation
accounts for factors of query execution such as I/O, CPU, and
communication.

Cost-Based Optimization
 Query optimization is the overall process of choosing the most
efficient means of executing a SQL statement.
 SQL is a nonprocedural language, so the optimizer is free to merge,
reorganize, and process in any order.
 The database optimizes each SQL statement based on statistics
collected about the accessed data.
 The optimizer determines the optimal plan for a SQL statement by
examining multiple access methods, such as full table scan or index
scans, different join methods such as nested loops and hash joins,
different join orders, and possible transformations.

Execution Plans
 An execution plan describes a recommended method of execution
for a SQL statement.
 The plan shows the combination of the steps Oracle Database uses
to execute a SQL statement.
 Each step either retrieves rows of data physically from the database
or prepares them for the user issuing the statement.
SELECT first_name, last_name

FROM hr.employees

WHERE department_id

IN (SELECT department_id

FROM hr.departments

WHERE location_id = 1800);

Analogy for the Optimizer

I need the most efficient route from point A to point B"

or

"I need the most efficient route from point A to point B by way of point
C."

"I want to arrive as fast as possible"

Or

"I want the easiest ride possible."


Optimizer Components

Query Transformer
Estimator

The estimator is the component of the optimizer that determines the


overall cost of a given execution plan.

Plan Generator

 The plan generator explores various plans for a query block by


trying out different access paths, join methods, and join orders.
 Many plans are possible because of the various combinations that
the database can use to produce the same result.
 The optimizer picks the plan with the lowest cost.

You might also like