You are on page 1of 13

Adarsh Vaish

July 9, 2009

Oracle Performance Tuning Outline Method

Agenda

Background

Achievement

Introduction to Outlines

Creating & Using Outlines

Deployment & Maintenance Activities

Pros and Cons

References

Q&A
2

Background

Between June to October 2008 timeframe, Daily Billing


Performance was becoming an Issue; it would run into
Business hours regularly.

Root Cause Analysis determined degradation of Auto-Invoice


Performance as the number one cause.

Auto-Invoice within Oces Oracle ERP system is a Standard


process and there have been no customizations.

Due to Oracle de-support risk and lack of source code, need


was to come up with an innovative method of Performance
tuning without any code changes or application of patches.

Oracle Stored Outlines aka Plan Stability method was used


for tuning Auto-Invoice performance without any code changes.
3

Achievement

Auto-Invoice Performance and Overall System Bandwidth gains


achieved are illustrated below:

Go-Live

Introduction to Outlines

Oracle optimizer tries to choose best execution path to retrieve or


update data; Hints can be used to force Oracle to use a specific or
desired execution path.

Starting from Oracle 8.1, it is no longer required to rewrite the


SQL to add hints, they can be provided without touching the code.

This feature is known as Stored Outlines, or Plan Stability, and the


concept is simple: Store information in the database that says: if
you see an SQL statement that looks like XXX then insert these
hints in the following places.

If Outline is enabled for the statement, Oracle automatically


considers the stored hints and tries to generate an execution plan
in accordance with those hints.

A stored outline consists of two components - an SQL statement


that you wish to control, and a list of hints that Oracle should apply
to that SQL statement. Both components are stored in the
database in a schema called outln.
5

Creating & Using Outlines

Outlines can be created automatically by Oracle or manually for


specific statements.

The automatic creation of outlines is controlled using the


create_stored_outlines parameter that can be set at session or
instance level using the following commands:
--Switch ON automatic creation of stored outlines.
ALTER SYSTEM SET create_stored_outlines=TRUE;
ALTER SESSION SET create_stored_outlines=TRUE;
--Switch OFF automatic creation of stored outlines.
ALTER SYSTEM SET create_stored_outlines=FALSE;
ALTER SESSION SET create_stored_outlines=FALSE;

Once this parameter is set at session or instance level outlines are


produced for all statements executed by the session or instance
respectively.

Creating & Using Outlines

Outlines can be generated for specific statements using the


CREATE OUTLINE statement or the DBMS_OUTLN package*

Using CREATE OUTLINE statement


CREATE OUTLINE <name> FOR CATEGORY <cat_name>
ON <select statement>;

Using Package DBMS_OUTLN

Run an SQL statement to get it into the shared pool


Identify the hash_value of SQL statement in the V$SQL view
Create an outline for the statement using
DBMS_OUTLN.CREATE_OUTLINE by supplying the hash_value as Input

The statement is assigned to an outline category to ease


administration. If the category is not specified the outline is
assigned to the default category.
* Need Grants CREATE ANY OUTLINE and EXECUTE_CATALOG_ROLE
7

Creating & Using Outlines

Outlines are stored in the OL$, OL$HINTS, and OL$NODES


tables

To check if a Outline is correctly created the following data


dictionary views can be queried

USER_OUTLINES
USER_OUTLINE_HINTS
ALL_OUTLINES
ALL_OUTLINE_HINTS
DBA_OUTLINES
DBA_OUTLINE_HINTS

To enable the Outlines we need to enable query rewrites and


indicate which outline category the instance or session should
use
ALTER SESSION SET query_rewrite_enabled=TRUE;
ALTER SESSION SET use_stored_outlines=<cat_name>;
8

Creating & Using Outlines

You can test if an outline is being used with the V$SQL view.
Query the OUTLINE_CATEGORY column in conjunction with
the SQL statement.

If an outline was applied, then this column contains the


category to which the outline belongs. Otherwise, it is NULL.

The OUTLINE_SID column tells you if this particular cursor is


using a public outline (value is 0) or a private outline (session's
SID of the corresponding session using it).
SELECT OUTLINE_CATEGORY, OUTLINE_SID
FROM
V$SQL
WHERE SQL_TEXT LIKE
'SELECT COUNT(*) FROM Emp%';
9

Deployment & Maintenance Activities

This tuning method involves identifying an optimal Execution


plan which is not getting used - Applications team; core
deployment activities are performed by the DBA team.

DBA Activities the First Time a New Outline is Created

Create a stored outline for original statement (Outline 1)


Create stored outline for hinted statement (Outline 2)
Swap the hints between Outline 1 and Outline 2

In a nutshell, get the outline for our original statement and make
it use the new execution plan as if it was hinted by swapping
the 2 Outlines.

DBA Maintenance Activities


A Database Trigger is created upon Startup to automatically
enable Outlines after any maintenance downtime.
10

Pros and Cons

Pros
Enormous benefits in terms of Performance tuning if source
code is not available or cannot be tuned via query rewrite.
As there is no code change involved following additional
benefits are achieved:
Mitigates Oracle de-support risk
Deployment time is greatly reduced
Can be used when upgrading from Rule Based to Query
Optimizer or during new Oracle database release.
Outlines can be moved between systems by category using
Import/Export, thus helping migrations between Test and
Production systems.

Cons
By using a stored outline, the system may be forcing the
optimizer to choose a different execution plan, so there
should be regular monitoring of the effects of the stored
outlines over time to make sure there is no negative impact.
11

References

Oracle Manuals specific to Database version

Metalink article 92202.1

Helpful Web URLs

http://download-west.oracle.com/docs/cd/B14117_01/server.
101/b10752/outlines.htm
http://www.dbazine.com/oracle/or-articles/jlewis4
http://www.dbazine.com/oracle/or-articles/jlewis5
http://www.psoug.org/reference/outlines.html
http://www.oracle-base.com/articles/misc/Outlines.php
http://asktom.oracle.com (search for Outlines)

12

Q&A

Questions?

13

You might also like