Академический Документы
Профессиональный Документы
Культура Документы
In general, SQL plan baselines are proactive, whereas SQL profiles are reactive.
Typically, you create SQL plan baselines before significant performance problems
occur. SQL plan baselines prevent the optimizer from using suboptimal plans in
the future.
The database creates SQL profiles when you invoke SQL Tuning Advisor, which
you do typically only after a SQL statement has shown high-load symptoms. SQL
profiles are primarily useful by providing the ongoing resolution of optimizer
mistakes that have led to suboptimal plans. Because the SQL profile mechanism
is reactive, it cannot guarantee stable performance as drastic database changes
occur.
The following graphic illustrates the difference:
SQL plan baselines reproduce a specific plan, whereas SQL profiles correct
optimizer cost estimates.
A SQL plan baseline is a set of accepted plans. Each plan is implemented using a
set of outline hints that fully specify a particular plan. SQL profiles are also
implemented using hints, but these hints do not specify any specific plan. Rather,
the hints correct miscalculations in the optimizer estimates that lead to
suboptimal plans. For example, a hint may correct the cardinality estimate of a
table.
Because a profile does not constrain the optimizer to any one plan, a SQL profile
is more flexible than a SQL plan baseline. For example, changes in initialization
parameters and optimizer statistics allow the optimizer to choose a better plan.
Oracle recommends that you use SQL Tuning Advisor. In this way, you follow the recommendations
made by the advisor for SQL profiles and plan baselines rather than trying to determine which
mechanism is best for each SQL statement.
select sql_handle, plan_name, enabled, accepted, fixed from
dba_sql_plan_baselines;
SQL_HANDLE
PLAN_NAME
ENA
ACC
FIX
-----------------------------------------------------------------------SYS_SQL_209d10fabbedc741
SYS_SQL_PLAN_bbedc741a57b5fc2
YES
NO
NO
SYS_SQL_209d10fabbedc741
SYS_SQL_PLAN_bbedc741f554c408
YES
YES
NO
DBA_ADVISOR_TASKS
DBA_ADVISOR_FINDINGS
DBA_ADVISOR_RECOMMENDATIONS
DBA_SQL_PROFILES
Outline
A stored outline is a collection of hints associated with a specific SQL statement that
allows a standard execution plan to be maintained, regardless of changes in the system
environment or associated statistics. Plan stability is based on the preservation of
execution plans at a point in time where the performance of a statement is considered
acceptable. The outlines are stored in the OL$, OL$HINTS, and OL$NODES tables, but
the [USER|ALL|DBA]_OUTLINES and [USER|ALL|DBA]_OUTLINE_HINTSviews should be
used to display information about existing outlines.
-- Enable stored outlines.
ALTER SESSION SET query_rewrite_enabled=TRUE;
ALTER SESSION SET use_stored_outlines=SCOTT_OUTLINES;
Drop--BEGIN
DBMS_OUTLN.drop_by_cat (cat => 'SCOTT_OUTLINES');
END;
/