Professional Documents
Culture Documents
Workload
Accept Profiles
SQL Tuning
Automatic High load Advisor 4
Generate
SQL Profiles
2
ADDM
DBA
3
Run SQL Tuning Advisor
AWR
To
p
SQ
L
Workload Auto matic
SQL Tuning
R
ep
or
4
ts
DBA
AWR
Weekly Daily Hourly Average Exec
Candidate List
1. Pull the top queries from the past week into four buckets:
Top for the past week
Top for any day in the past week
Top in any hour (single snapshot)
Top by average single execution
2. Combine four buckets into one, assigning weights
3. Cap at 150 queries per bucket
Pick
… Tune Test Accept Tune …
candidate
S1 P1 P1 S2
SQL
Maintenance
Window
Restructure
SQL New
SQL profile
Existing N 3X Y
Accept profile
Indexes profile? benefit?
N
Y
3X N
Ignore new profile
benefit?
Stale
stats
Y
Replace profile
GATHER_STATS_JOB
• Autotask configuration:
– On/off switch
– Maintenance windows running tuning task
– CPU resource consumption of tuning task
• Task parameters:
– SQL Profile implementation automatic/manual switch
– Global time limit for tuning task
– Per-SQL time limit for tuning task
– Disable test-execute to save time
– Max SQL profiles accepted per day / overall
– Task execution expiration period
• Use DBMS_SQLTUNE:
– SET_TUNING_TASK_PARAMETER
– EXECUTE_TUNING_TASK
– REPORT_AUTO_TUNING_TASK
• Use DBMS_AUTO_TASK_ADMIN:
– ENABLE
– DISABLE
• Dictionary views:
– DBA_ADVISOR_EXECUTIONS
– DBA_ADVISOR_SQLSTATS
DBA_ADVISOR_SQLPLANS
time
Baseline Templates
Creating baselines for future time periods allows you to mark time periods that you know will be
interesting. For example, you may want the system to automatically generate a baseline for every
Monday morning for the whole year, or you can ask the system to generate a baseline for an
upcoming holiday weekend if you suspect that it is a high-volume weekend. Previously, you could
only create baselines on snapshots that already existed. A nightly MMON task goes through all the
templates for baseline generation and checks to see if any time ranges have changed from the
future to the past within the last day. For the relevant time periods, the MMON task then creates a
baseline for the time period.
….. T4 T5 T6 ….. Tx Ty Tz
DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE_TEMPLATE ( -
start_time IN time stamp ,
end_time IN time stamp ,
baseline_name IN VARCHAR2 ,
template_name IN VARCHAR2 ,
expiration IN NUMBER ,
dbid IN NUMBER DEFAULT NULL ) ;
DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE_TEMPLATE ( -
day_of_week IN VARCHAR2,
hour_in_day IN NUMBER,
duration IN NUMBER,
start_time IN DATE,
end_time IN DATE
baseline_name_prefix IN VARCHAR2,
template_name IN VARCHAR2,
expiration IN NUMBER DEFAULT NULL,
dbid IN NUMBER DEFAULT NULL );
DBMS_WORKLOAD_REPOSITORY Package
Oracle Database 11g offers the above set of PL/SQL interfaces in the
DBMS_WORKLOAD_REPOSITORY package for administration and filtering.
MODIFY_BASELINE_WINDOW_SIZE allows you to modify the size of the
SYSTEM_MOVING_WINDOW.
START_TIME Start Time for the future Baseline. Used for ‘SINGLE’. For
‘REPEATING’, this is the Effective Start Time where
Baselines should start being generated.
END_TIME End Time for the future Baseline. Used for ‘SINGLE’. For
‘REPEATING’, this is the Effective End Time where
Baselines should stop being generated.
DAY_OF_WEEK Day of week to create baseline. Is one of the following
values (‘SUNDAY’, ‘MONDAY’, ‘TUESDAY’, ‘WEDNESDAY’,
‘THURSDAY’, ‘FRIDAY’, ‘SATURDAY’, ‘ALL’). Used for
‘REPEATING’.
HOUR_IN_DAY Value of 0-23 to specify the Hour in the Day to create the
Baseline for. Used for ‘REPEATING’.
Threshold
adapts
automatically
Observed
value
Baseline
calculation
• V$SYSTEM_EVENT:
– TOTAL_WAITS_FG
– TOTAL_TIMEOUTS_FG
– TIME_WAITED_FG
– AVERAGE_WAIT_FG
– TIME_WAITED_MICRO_FG
• V$SYSTEM_WAIT_CLASS:
– TOTAL_WAITS_FG
– TIME_WAITED_FG
V$SYSTEM_EVENT has five new NUMBER columns that represent the statistics from purely
foreground sessions:
• TOTAL_WAITS_FG
• TOTAL_TIMEOUTS_FG
• TIME_WAITED_FG
• AVERAGE_WAIT_FG
• TIME_WAITED_MICRO_FG
V$SYSTEM_WAIT_CLASS has two new NUMBER columns that represent the statistics from
purely foreground sessions:
• TOTAL_WAITS_FG
• TIME_WAITED_FG
Oracle Database 10g introduced the execution of some automated maintenance tasks during a
maintenance window. Specifically the automated task were: statistics collection and segment
advisor.
With Oracle Database 11g, the Automated Maintenance Tasks feature relies on the Resource
Manager being enabled during the Maintenance Windows. The idea is to prevent maintenance
work from consuming excessive amounts of system resources.
In order to facilitate mapping of automated tasks to specific windows, the above Maintenance
Windows are created in place of the existing WEEKNIGHT_WINDOW and
WEEKEND_WINDOW windows inside the MAINTENANCE_WINDOW_GROUP window
group.
You are still completely free to define other Maintenance Windows, as well as change start times
and durations for the windows listed above. Likewise, any Maintenance Windows that are deemed
unnecessary can be disabled or removed. The operations can be done using EM or Scheduler
interfaces.