Sie sind auf Seite 1von 2

SQL Profiles do NOT freeze or lock in an execution plan but Stored outlines

will!

Or…

How To Show All Stored Outline Hints to force a query to follow a specific
execution plan
See also: “How To – show the complete list of stored outline hints to force a fast execution Plan.doc”

Source: “Oracle® Database Performance Tuning Guide 10g Release 2 (10.2)”,


http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/sql_tune.htm

It is important to note that the SQL Profile does not freeze the execution plan of a SQL statement, as done by stored
outlines. As tables grow or indexes are created or dropped, the execution plan can change with the same SQL Profile.
The information stored in it continues to be relevant even as the data distribution or access path of the corresponding
statement change. However, over a long period of time, its content can become outdated and would have to be
regenerated. This can be done by running Automatic SQL Tuning again on the same statement to regenerate the SQL
Profile.

How To Create a Stored Outline


BAM Note: Update Tuesday, January 27, 2009

Method #1
1) GRANT CREATE ANY OUTLINE TO <username>;
2) enable storing of outlines using this command
ALTER SESSION SET CREATE_STORED_OUTLINES=TRUE;
ALTER SESSION SET USE_STORED_OUTLINES=TRUE;

3) CREATE OUTLINE <outline_name> ON select ….;


4) immediately disable storing of outlines using this command:
alter session set CREATE_STORED_OUTLINES = FALSE;

How to enable stored outlines and use them once they are stored
ALTER SESSION SET query_rewrite_enabled=TRUE;
ALTER SESSION SET use_stored_outlines= CITIBANK_OUTLINES; (or whatever your category was)

How to get a list of all the hints that would make up a stored outline
Method #1
1) Explain the plan in your fast server
2) Use this command to format the execution plan / explain plan:
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY( null, null, 'all +outline')) ;
3) Your list of hints is found in the “Outline Data” section
a. Important: Copy all the hints except the “IGNORE_OPTIM_EMBEDDED_HINTS” hint
b. Also, you won’t really need the “BEGIN_OUTLINE_DATA” or “END_OUTLINE_DATA” hints
4) Use all the hints in the SQL statement

Method #2
Create a stored outline then query the USER_OUTLINE_HINTS view like this:
COLUMN hint FORMAT A50
SELECT node, stage, join_pos, hint FROM user_outline_hints WHERE name = '&OUTLINE_NAME';

How to send a stored outline to a customer


BAM has never tried this, but he thinks it may be possible to use Oracle’s export utility to export the data in the OL$
and OL$HINTS tables (they are owned by the OUTLN oracle account) like this:

Export the OL$ and OL$HINTS tables:


EXP.EXE OUTLN/OUTLN FILE=exp_file.dmp TABLES = 'OL$' 'OL$HINTS' SILENT=y

Then the idea would be to send the resulting dmp file to the customer, tell them to import it.
Then they must enable outlines using these commands:

ALTER SESSION SET query_rewrite_enabled=TRUE;


ALTER SESSION SET use_stored_outlines= CITIBANK_OUTLINES; (or whatever your category was)

Das könnte Ihnen auch gefallen