Beruflich Dokumente
Kultur Dokumente
D50081GC10
Edition 1.0
July 2007
D51900 L$
Authors Copyright 2007, Oracle. All rights reserved.
James Spiller This course in any form, including its course labs and printed matter, contains
Kesavan Srinivasan proprietary information that is the exclusive property of Oracle. This course and the
information contained herein may not be disclosed, copied, reproduced, or distributed
Jenny Tsai
to anyone outside Oracle without prior written consent of Oracle. This course and its
Jean-Francois Verrier contents are not part of your license agreement nor can they be incorporated into any
James Womack contractual agreement with Oracle or its subsidiaries or affiliates.
This course is for informational purposes only and is intended solely to assist you in
Technical Contributors planning for the implementation and upgrade of the product features described. It is
and Reviewers not a commitment to deliver any material, code, or functionality, and should not be
relied upon in making purchasing decisions. The development, release, and timing of
Maqsood Alam any features or functionality described in this document remain at the sole discretion
Kalyan Bitra of Oracle.
Harald Van Breederode This document contains proprietary information and is protected by copyright and
Edward Choi other intellectual property laws. You may copy and print this document solely for your
own use in an Oracle training course. The document may not be modified or altered in
Al Flournoy any way. Except where your use constitutes "fair use" under copyright law, you may
Andy Fortunak not use, share, download, upload, copy, print, display, perform, reproduce, publish,
Gerlinde Frenzen license, post, transmit, or distribute this document in whole or in part without the
express authorization of Oracle.
Greg Gagnon
Joel Goodman The information contained in this document is subject to change without notice. If you
find any problems in the document, please report them in writing to: Oracle University,
Hansen Han
500 Oracle Parkway, Redwood Shores, California 94065 USA.
Uwe Hesse Restricted Rights Notice
Sunil Hingorani
If this documentation is delivered to the United States Government or anyone using
Magnus Isaksson the documentation on behalf of the United States Government, the following notice is
Susan Jang applicable:
Martin Jensen
U.S. GOVERNMENT RIGHTS
Pete Jones The U.S. Governments rights to use, modify, reproduce, release, perform, display, or
Yash Kapani disclose these training materials are restricted by the terms of the applicable Oracle
license agreement and/or the applicable U.S. Government contract.
Pierre Labrousse
Richard.W.Lewis Trademark Notice
Hakan Lindfors
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other
Russ Lowenthal names may be trademarks of their respective owners.
Kurt Lysy
Silvia Marrone This document is not warranted to be error-free.
Heejin Park
Editors
Jagannath Poosarla
Eric Siglin Raj Kumar
Ranbir Singh Daniel Milne
Jeff Skochil Vijayalakshmi Narasimhan
George Spears Atanu Raychaudhuri
Birgitte Taagholt Richard Wallis
Glenn Tripp
Anthony Woodell
Publishers
Sujatha Nagendra
Graphic Designers Srividya Rameshkumar
Rajiv Chandrabhanu Michael Sebastian
Samir Mozumdar Jobi Varghese
Introduction
Overview
This course is designed to introduce you to the new features of Oracle Database 11g that are
applicable to the work usually performed by database administrators and related personnel. The
course does not attempt to provide every detail about a feature or cover aspects of a feature that
were available in previous releases (except when defining the context for a new feature or
comparing past behavior with current behavior). Consequently, the course is most useful to you
if you have already administered other versions of Oracle databases, particularly Oracle
Database 10g. Even with this background, you should not expect to be able to implement all of
the features discussed in the course without supplemental reading, especially the Oracle
Database 11g documentation.
The course consists of instructor-led lessons and demonstrations, plus many hands-on practices
and demos that enable you to see for yourself how certain new features behave. As with the
course content in general, these practices are designed to introduce you to the fundamental
aspects of a feature. They are not intended to test your knowledge of unfamiliar syntax or to
provide an opportunity for you to examine every nuance of a new feature. The length of this
course precludes such activity. Consequently, you are strongly encouraged to use the provided
scripts to complete the practices rather than struggle with unfamiliar syntax.
Manageability
Availability
Performance
Business intelligence and data warehousing
Security
Information management
Content management
XML
Oracle Text
Spatial
Multimedia and medical imaging
Application development
PL/SQL
.NET
PHP
SQL Developer
Auto-tuning
Advisory
Instrumentation
Recovery
Replication
RAC
Memory
Schema
Apps/SQL
Backup
Storage
Management Automation
Oracle Database 11g continues the effort begun in Oracle9i Database and carried on through
Oracle Database 10g to dramatically simplify and ultimately, fully automate the tasks that DBAs
must perform. What is new in Oracle Database 11g is Automatic SQL Tuning with self-learning
capabilities. Other new capabilities include automatic, unified tuning of both SGA and PGA
memory buffers, and new advisors for partitioning, database repair, streams performance, and
space management. Enhancements to Oracle Automatic Database Diagnostic Monitor (ADDM)
give it a better global view of performance in Oracle Real Application Clusters (RAC)
environments and improved comparative performance analysis capabilities.
Manage Storage 2 1
Manage Change 3, 4, 5 2
Miscellaneous 16 5
Suggested Schedule
The lessons in this guide are arranged in the order in which you will probably study them in the
class. The lessons are grouped into topic areas, but they are also organized by other criteria,
including the following:
A feature is introduced in an early lesson and then referenced in later lessons.
Topics alternate between difficult and easy to facilitate learning.
Lessons are supplemented with hands-on practices throughout the course to provide regular
opportunities for you to explore what you are learning.
If your instructor teaches the class in the sequence in which the lessons are printed in this guide,
the class should run approximately as shown in the schedule. Your instructor, however, may vary
the sequence of the lessons for a number of reasons, including:
Customizing material for a specific audience
Covering a topic in a single day instead of splitting the material across two days
Maximizing the use of course resources (such as hardware and software)
STARTUP UPGRADE
STARTUP UPGRADE enables you to open a database based on an earlier Oracle Database release. It
also restricts logons to AS SYSDBA sessions, disables system triggers, and performs additional
operations that prepare the environment for the upgrade (some of which are listed in the slide).
To upgrade the candidate database, follow the directions below:
1. Set the ORACLE_SID correctly.
The oratab file should point to your Oracle Database 11g Oracle home. The following
environment variables point to the Oracle Database 11g directories:
ORACLE_HOME
PATH
2. Log in to the system as the owner of the Oracle Database 11g Oracle home directory.
3. At system prompt, change to the ORACLE_HOME/rdbms/admin directory and SQL*Plus.
4. Connect to the database instance as a user with SYSDBA privileges.
5. Start up the instance by issuing the following command:
SQL> STARTUP UPGRADE
Advantages
Automates all tasks
Performs both release and patch set upgrades
Supports RAC, Single Instance, and ASM
Informs the user and fixes upgrade prerequisites
Automatically reports errors found in spool logs
Provides complete HTML report of the upgrade process
Command-line interface allows ISVs to automate
Disadvantages
Offers less control over individual upgrade steps
Recoverability
Performs a backup of the database before upgrade
Can restore the database after upgrade (if needed)
Runs all necessary scripts to perform the upgrade
Displays upgrade progress at a component level
Configuration checks
Automatically makes appropriate adjustments to the
initialization parameters
Checks for adequate resources such as SYSTEM
tablespace size, rollback segment size, and redo log size
Checks disk space for auto-extended data files
Creates mandatory SYSAUX tablespace
Configuration files
Creates init.ora and spfile in the new ORACLE_HOME
Updates network configurations
Uses OFA-compliant locations
Updates database information on OID
Oracle Enterprise Manager
DBCA allows you to set up and configure EM DB Control.
DBCA allows you to register a database with EM Grid
Control.
If EM is in use, DBCA enables you to upgrade the EM
catalog and make the necessary configuration changes.
Logging and tracing
Writes detailed trace and logging files
(ORACLE_BASE/cfgtoollogs/dbua/<sid>/upgradeNN)
Command-Line Syntax
When invoked with the -silent command line option, the DBUA operates in silent mode. In the
silent mode, the DBUA does not present a user interface. It also writes any messages (including
information, errors, and warnings) to a log file in
ORACLE_HOME/cfgtoollogs/dbua/SID/upgraden, where n is the number of upgrades that the
DBUA has performed as of this upgrade.
For example, the following command upgrades a database named ORCL in the silent mode:
$ dbua -silent -dbName ORCL &
Here is a list of important options that you can use:
-backupLocation directory specifies a directory to back up your database before the
upgrade starts.
-postUpgradeScripts script [, script ] specifies a comma-delimited list of SQL
scripts. Specify complete path names. The scripts are executed at the end of the upgrade.
-initParam parameter=value [, parameter=value ] specifies a comma-delimited list
of initialization parameter values of the form name=value.
-emConfiguration {CENTRAL|LOCAL|ALL|NOBACKUP|NOEMAIL|NONE}specifies the
Oracle Enterprise Manager management options.
Note: For more information about these options, see the Oracle Database Upgrade Guide 11g.
Recovery Configuration
The Recovery Configuration page enables you to designate a Flash Recovery Area for your database.
If you selected Move Database Files during Upgrade, or if an Oracle Express Edition database is
being upgraded to Oracle Enterprise Edition, then a Flash Recovery Area must be configured. If a
Flash Recovery Area is already configured, the current settings are retained but the screen is
displayed to enable you to override these values.
Click Next.
Network Configuration
If the DBUA detects that multiple listeners are configured, the Network Configuration for the
database page appears. This page has two tabs. The Listeners tab is displayed if you have more than
one listener. The Directory Service tab appears if you have the directory services configured.
On the Listeners tab, select one of the following options:
Register this database with all the listeners
Register this database with selected listeners only
If you choose to register selected listeners only, you must select the listeners that you want from the
Available Listeners list, and then use the arrow buttons to move them to the Selected Listeners list. If
you want to register your database with a directory service, click the Directory Service tab.
On the Directory Service tab, select one of the following options:
Yes, register the database: Selecting this option enables client computers to connect to this
database without a local name file (tnsnames.ora) and also enables them to use the Oracle
Enterprise User Security feature.
No, dont register the database
If you choose to register the database, you must also provide a user distinguished name (DN) in the
User DN field and a password for that user in the Password field. An Oracle Wallet is created as part
of database registration. It contains credentials suitable for password authentication between this
database and the directory service. Enter a password in both the Wallet Password field and the
Confirm Password field. Then click Next.
Oracle Database 11g: New Features for Administrators 1 - 36
Recompile Invalid Objects
USER_DUMP_DEST
BACKGROUND_DUMP_DEST DIAGNOSTIC_DEST
CORE_DUMP_DEST
UNDO_MANAGEMENT not set implies AUTO mode.
To migrate to automatic undo management:
1. Set UNDO_MANAGEMENT=MANUAL.
2. Execute your workload.
3. Execute the DBMS_UNDO_ADV.RBU_MIGRATION function.
4. Create an undo tablespace based on previous size result.
5. Set UNDO_MANAGEMENT=AUTO.
cp libodm11.so libodm11.so_stub
3 ln -s libnfsodm11.so libodm11.so
/etc/mtab
SVR_ID V$DNFS_FILES
Join column
SVR_ID V$DNFS_CHANNELS
Note: In this lesson, the term ASM data extent is shortened to extent.
Secondary
Primary
extent
extent
Secondary
Primary
extent
extent
P S
Site A Site B
P P: Primary AU S
S: Secondary AU
Setup
On first instance
ASM_PREFERRED_READ_FAILURE_GROUPS=DATA.SITEA
On second instance
ASM_PREFERRED_READ_FAILURE_GROUPS=DATA.SITEB
Monitor
P S P S S S S P
Only two failure groups: one for each instance Max four failure groups: two for each instance
P S S
SYSASM Role
This feature introduces a new SYSASM role that is specifically intended for performing ASM
administration tasks. Using the SYSASM role instead of the SYSDBA role improves security by
separating ASM administration from database administration.
With Oracle Database 11g, Release 1, the OS group for SYSASM and SYSDBA is the same, and the
default installation group for SYSASM is dba. In a future release, separate groups will have to be
created, and SYSDBA users will be restricted in ASM instances.
As a member of the dba group, you can currently connect to an ASM instance by using the first
statement in the slide.
You also have the ability to use the combination of CREATE USER and GRANT SYSASM SQL
statements from an ASM instance to create a new SYSASM user. This can be useful for remote ASM
administration. These commands update the password file of each ASM instance and do not need the
instance to be up and running. Similarly, you can revoke the SYSASM role from a user by using the
REVOKE command, and you can drop a user from the password file by using the DROP USER
command.
The V$PWFILE_USERS view integrates a new column called SYSASM, which indicates whether the
user can connect with SYSASM privileges (TRUE) or not (FALSE).
Note: With Oracle Database 11g, Release 1, if you log in to an ASM instance as SYSDBA, warnings
are written in the corresponding alert.log file.
Oracle Database 11g: New Features for Administrators 2 - 16
Using EM to Manage ASM Users
User-created directories
Templates
Disk group compatibility md_backup
Disk group name full
Disk names and failure groups
newdg
lsdsk
ASMCMD Extensions
ASMCMD is extended to include ASM metadata backup and to restore functionality. This
provides the ability to re-create a preexisting ASM disk group with the exact template and alias
directory structure. Currently, if an ASM disk group is lost, it is possible to restore the lost files
by using RMANbut you must manually re-create the ASM disk group and any required user
directories or templates.
ASM metadata backup and restore (AMBR) works in two modes:
- In backup mode, AMBR parses ASM fixed tables and views to gather information about
existing disks and failure group configurations, templates, and alias directory structures.
It then dumps this metadata information to a text file.
- In restore mode, AMBR reads the previously generated file to reconstruct the disk group
and its metadata. You have the ability to control AMBR behavior in restore mode to do a
full, nodg, or newdg restore. The difference among the three submodes is in whether
you want to include the disk group creation and change its characteristics.
The lsdsk command lists ASM disk information. This command can run in two modes:
- In connected mode, ASMCMD uses the V$ and GV$ views to retrieve disk information.
- In nonconnected mode, ASMCMD scans disk headers to retrieve disk information, using an
ASM disk string to restrict the discovery set. The connected mode is always attempted first.
Production
database
Cursor cache
Production Test
database database
Comparison Report
Use the SQL Performance Analyzer Task Result page to see the Replay Trial Comparison Report.
The following general details are displayed:
Task details such as name, owner, and description of the task
Name and owner of the SQL Tuning Set
Total number of SQL statements and any SQL statements with errors. Click the SQL Statements
With Errors link to access the Errors table.
The Replay Trials being compared and comparison metric being used
In addition to these details, you can view the following:
Projected Workload [Comparison Metric]: This chart shows the projected workload for each
Replay Trial based on the comparison metric along with the improvement, regression, and
overall impact. Click the impact links to drill down to the complete list of SQL statements in
each category.
SQL Statement Count: This chart shows the number of SQL statements that have improved,
regressed, or not changed performance based on the comparison metric. The colors of the bars
indicate whether the plan changed between the two trial runs. Click the links or the data buckets
to access the SQL Statement Count Details page, where you can see a list of SQL statements,
and then click a SQL ID to access the SQL details.
Top 10 SQL Statements Based on Impact on Workload table: This table allows you to
click a specific SQL ID to drill down to the corresponding SQL Details page.
Oracle Database 11g: New Features for Administrators 3 - 25
Comparison Report
Preventing Regressions
Instead of using SQL Tuning Advisor to tune your regressing statements, you can also prevent
regressions by using the SQL plan baselines. You can do so from the SQL Performance Analyzer
Task Result page by clicking the Create SQL Plan Baselines button.
Note: For more information about SQL plan baselines, refer to the lesson titled SQL Plan
Manageability.
Make changes
Statement log
Plan history
Plan history
Plan
baseline Plan
GB baseline
GB GB GB
HJ GB GB SQL
HJ HJ HJ HJ HJ HJ profile
Repeatable HJ HJ HJ
HJ HJ
SQL
statement
Plan History
Plan
baseline
GB
GB GB
HJ
HJ HJ HJ
HJ HJ Automatic
SQL Tuning
task
Plan verification before
integration to baseline
load_plans_from_cursor_cache
ba Pl lin
e
GB
an se
Pl lin
load_plans_from_sqlset
1 e HJ
HJ
GB
HJ
HJ
GB alter_sql_plan_baseline
HJ
2
HJ
*_stgtab_baseline
GB
HJ 3
HJ Staging
Cursor table
cache
Plan history
ba
an se
Pl GB lin
e 4
HJ
HJ
DBA
Plan history
ba
an se
Automatic Pl lin
e
GB
SQL Tuning HJ
HJ
DBA GB
HJ
HJ
>?
SQL
Tuning
Advisor
Plan history
ba
an se
GB
Pl lin
e
GB
Enabled but HJ
Enabled and
HJ
not accepted HJ HJ
accepted
Plan history
Yes
Plan
No
baseline
GB
GB GB
HJ
GB
HJ HJ HJ
Plan part HJ HJ
HJ
Yes of baseline?
HJ
No
GB GB GB GB
Yes No
dbms_xplan.display(,'BASIC +NOTE) HJ HJ > HJ HJ
or HJ HJ HJ HJ
plan_table(other_xml)
HJ HJ HJ HJ
No plan No plan
regressions regressions
DBA
GB HJ HJ
Well-
tuned HJ HJ HJ
plan HJ Well-tuned Baseline
plan plans
staging table
Oracle Database 10g Development database
HJ HJ
Regressing
statements No plan
regressions
After
change
O_F_E=11
optimizer_features_enable
GB GB GB
HJ HJ HJ
HJ HJ HJ Well-
tuned
plans
Oracle Database 10g
optimizer_features_enable=10.2.0.2 optimizer_features_enable=11.1.0.1
optimizer_capture_plan_baselines=true optimizer_capture_plan_baselines=true
Plan baseline
GB GB GB
GB
GB Well- HJ HJ HJ
HJ tuned
HJ HJ HJ HJ
HJ plans
HJ
DBA_SQL_MANAGEMENT_CONFIG
53
Database Replay
Oracle Database 11g provides specific solutions to the challenges described in the preceding slides.
Database Replay allows you to test the impact of a system change by replaying real-world workload
on the test system before it is exposed to a production system. The production workload (including
transaction concurrency and dependency) of the database server is recorded over an illustrative
period of time (for example, a peak period). This recorded data is used to replay the workload on a
test system that has been appropriately configured. You gain a high degree of confidence in the
overall success of the database change by subjecting the database server in a test system to a
workload that is practically indistinguishable from a production workload.
Capture directory
Database
backup
Production
database
Capture directory
Database
backup
Production
Process
database capture
Test
system
with
Database changes
backup
Test
database
Supported changes
Database upgrades, patches
Production
Schema, parameters system
Supported
All SQL (DML, DDL, PL/SQL) with practically all types of binds
Full LOB functionality (cursor-based and direct OCI)
Local transactions
Logins and logoffs
Session switching
Limited PL/SQL RPCs
Limitations
Direct path load, import/export
OCI-based object navigation (ADTs) and REF binds
Streams, non-PL/SQL-based AQ
Distributed txns, remote describe/commit operations
Flashback (Database and Query)
Shared Server
Supported Workloads
The slide shows supported and nonsupported database operations.
Capture Considerations
You perform the following tasks in the planning phase of the workload recording:
Check the database backup strategy, ensuring that the database can be restored to StartSCN
when the recording starts.
Plan the capture period by selecting it based on the application and the peak periods. You can
use existing manageability features such as Automatic Workload Repository (AWR) and Active
Session History (ASH) to select an appropriate period based on workload history. The starting
time for capture should be carefully planned because it is recommended that you shut down and
restart the database before starting the capture.
Specify the location of the workload capture data. You must set up a directory that is to be used
to store the workload capture data. You should provide ample disk space because the recording
stops if there is insufficient disk space. However, everything captured up to that point is usable
for replay.
Define capture filters for user sessions that are not to be captured. You can specify a recording
filter to skip sessions that should not be captured.
No new privileges or user roles are introduced with the Database Replay functionality. The
recording user and replay user must have either the SYSDBA or SYSOPER privilege. This is
because a user having only SYSOPER or SYSDBA can start up or shut down the database to start
the recording. Correct operating system (OS) privileges should also be assigned so that the user
is able to access the recording, replay directories, and manipulate the files under those
directories.
Oracle Database 11g: New Features for Administrators 5 - 11
Replay Considerations
Replay Considerations
The preprocess phase is a once-only required action for the specified database version. After the
necessary metadata has been created, you can replay the workload as many times as required.
You must restore the replay database to match the capture database at the start of the workload
capture. A successful replay depends on the application transactions accessing the application data
identical to that on the capture system. You can choose to restore the application data using point-in-
time recovery, flashback, and import/export.
Synchronized replay:
Ensures minimal data divergence
Commit-based synchronization
Unsynchronized replay:
Useful for load/stress testing
Original commit ordering not honored
High data divergence
Think time options:
Auto (default)
Adjust think time to maintain the captured request rate:
0%: No think time (highest possible request rate)
<100%: Higher request rate
100%: Exact think time
>100%: Lower request rate
Login time options
Percentage (default is 100%)
Replay Options
The following replay options can be modified while replaying your workload:
The synchronization parameter determines whether synchronization will be used during
workload replay. If this parameter is set to TRUE, the COMMIT order in the captured workload
will be preserved during replay and all replay actions will be executed only after all dependent
COMMIT actions have completed. The default value is TRUE.
The think_time_scale parameter scales the elapsed time between two successive user
calls from the same session; it is interpreted as a percentage value. Use this parameter to
increase or decrease the replay speed. Setting this parameter to 0 will send user calls to the
database as fast as possible during replay. The default value is 100.
The think_time_auto_correct parameter corrects the think time (based on the
think_time_scale parameter) between calls, when user calls take longer to complete
during replay than during capture. It is interpreted as a percentage value.
The connect_time_scale parameter scales the elapsed time from when the workload
capture started to when the session connects with the specified value; it is interpreted as a
percentage. Use this option to manipulate the session connect time during replay. The default
value is 100.
Note: During workload capture, elapsed time is measured by user time and user think time. User
time is the elapsed time of a user call to the database. User think time is the elapsed time while the
user waits between issuing calls. During workload replay, elapsed time is measured by user time,
user think time, and synchronization time.
Oracle Database 11g: New Features for Administrators 5 - 14
Replay Analysis
Data divergence
Number of rows compared for each call (queries, DML)
Error divergence
New errors
Mutated errors
Errors that have disappeared
Performance
Capture and Replay report
ADDM report
ASH report for skew analysis
AWR report
Replay Analysis
There may be some divergence of the replay compared to what was recorded. For example, when
replaying on a newer version of the RDBMS, a new algorithm may cause specific requests to be
faster, resulting in divergence appearing as a faster execution. This is considered a desirable
divergence. Another example of a divergence is when a SQL statement returns fewer rows during
replay than those returned during recording. This is clearly undesirable.
For data divergence, the result of an action can be considered as:
The result set of SQL query
An update to persistent database state
A return code or error code
Performance divergence is useful in determining how new algorithms introduced in the replay
system may affect overall performance. There are numerous factors that can cause replay divergence.
Though some of them cannot be controlled, others can be mitigated. It is the task of the DBA to
understand the workload run-time operations and take the necessary actions to reduce the level of
record-and-replay divergence.
Online divergence should aid the decision to stop a replay that has diverged significantly. The results
of the replay before the divergence may still be useful, but further replay would not produce reliable
conclusions. Offline divergence reporting is used to determine how successful the replay was after
the replay has finished.
DBMS_WORKLOAD_CAPTURE DBMS_WORKLOAD_REPLAY
START_CAPTURE PROCESS_CAPTURE
FINISH_CAPTURE INITIALIZE_REPLAY
ADD_FILTER PREPARE_REPLAY
DELETE_FILTER START_REPLAY
DELETE_CAPTURE_INFO CANCEL_REPLAY
GET_CAPTURE_INFO() DELETE_REPLAY_INFO
EXPORT_AWR REMAP_CONNECTION
IMPORT_AWR() EXPORT_AWR
REPORT() IMPORT_AWR
GET_REPLAY_INFO
REPORT
DECLARE
cap_id NUMBER;
rep_id NUMBER;
rep_rpt CLOB;
BEGIN
cap_id := DBMS_WORKLOAD_REPLAY.GET_REPLAY_INFO(dir => 'jun07');
/* Get the latest replay for that capture */
SELECT max(id) INTO rep_id
FROM dba_workload_replays
WHERE capture_id = cap_id;
rep_rpt := DBMS_WORKLOAD_REPLAY.REPORT(replay_id => rep_id,
format => DBMS_WORKLOAD_REPLAY.TYPE_TEXT);
END;
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
o
4
rt
s DBA
AWR
Weekly Daily Hourly Avrg execution
Candidate list
1. Pull the top queries from the past week into four buckets:
y Top for the past week
y Top for any day in the past week
y Top in any single snapshot
y 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
benefit? Accept profile
Indexes profile?
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
Test-execute mode disabled to save time
Maximum number of SQL profiles automatically
implemented per execution as well as overall
Task execution expiration period
DBA Controls
Here is a PL/SQL control example for the Automatic SQL Tuning task:
BEGIN
dbms_sqltune.set_tuning_task_parameter('SYS_AUTO_SQL_TUNING_TASK',
'LOCAL_TIME_LIMIT', 1400);
dbms_sqltune.set_tuning_task_parameter('SYS_AUTO_SQL_TUNING_TASK',
'ACCEPT_SQL_PROFILES', 'TRUE');
dbms_sqltune.set_tuning_task_parameter('SYS_AUTO_SQL_TUNING_TASK',
'MAX_SQL_PROFILES_PER_EXEC', 50);
dbms_sqltune.set_tuning_task_parameter('SYS_AUTO_SQL_TUNING_TASK',
'MAX_AUTO_SQL_PROFILES', 10002);
END;
The last three parameters in this example are supported only for the Automatic SQL Tuning task.
You can also use parameters such as LOCAL_TIME_LIMIT, or TIME_LIMIT, which are valid
parameters for the traditional SQL tuning tasks. One important example is to disable test-execute
mode (to save time) and to use only execution plan costs to decide about the performance by using
the TEST_EXECUTE parameter.
In addition, you can control when the Automatic SQL Tuning task runs and the CPU resources that it
is allowed to use.
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
MY_REPT
--------------------------------------------------------------------------------
GENERAL INFORMATION SECTION
Tuning Task Name : SYS_AUTO_SQL_TUNING_TASK
Tuning Task Owner : SYS
Workload Type : Automatic High-Load SQL Workload
Scope : COMPREHENSIVE
Global Time Limit(seconds) : 3600
Per-SQL Time Limit(seconds) : 1200
Number of SQLs with Statistic Findings : 1
Number of SQLs with SQL profiles recommended : 2
Number of SQLs with SQL profiles implemented : 2
Number of SQLs with Index Findings : 1
Number of SQLs with Errors : 1
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 create baselines only on snapshots that already existed. With Oracle Database
11g, 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
BEGIN
DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE_TEMPLATE (
start_time => to_date('21-JUN-2008','DD-MON-YYYY'),
end_time => to_date('21-SEP-2008','DD-MON-YYYY'),
baseline_name => 'FALL08',
template_name => 'FALL08',
expiration => NULL ) ;
END;
BEGIN
DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE_TEMPLATE (
day_of_week => 'SATURDAY',
hour_in_day => 6,
duration => 20,
start_time => to_date('21-JUN-2007','DD-MON-YYYY'),
end_time => to_date('21-JUN-2008','DD-MON-YYYY'),
baseline_name_prefix => 'SAT_MAINT_WIN'
template_name => 'SAT_MAINT_WIN',
expiration => 90,
dbid => NULL );
END;
DBMS_WORKLOAD_REPOSITORY Package
The slide shows the set of PL/SQL interfaces offered by Oracle Database 11g in the
DBMS_WORKLOAD_REPOSITORY package for administration and filtering.
MODIFY_BASELINE_WINDOW_SIZE enables you to modify the size of the
SYSTEM_MOVING_WINDOW.
Baseline Views
The data dictionary views supporting the AWR baselines have changed.
DBA_HIST_BASELINE: Modified View
DBA_HIST_BASELINE has been modified to support the SYSTEM_MOVING_WINDOW baseline
and the baselines generated from templates. Additional information includes the date created, time of
last statistics calculation, and type of baseline.
DBA_HIST_BASELINE_DETAILS: New View
DBA_HIST_BASELINE_DETAILS displays information that allows you to determine the validity
of a given baseline, such as whether there was a shutdown during the baseline period and the
percentage of the baseline period that is covered by the snapshot data.
DBA_HIST_BASELINE_TEMPLATE: New View
DBA_HIST_BASELINE_TEMPLATE holds the baseline templates. This view provides the
information needed by MMON to determine when a baseline will be created from a template and when
the baseline should be removed.
For details, see Oracle Database Reference 11g.
Maintenance Windows
Oracle Database 10g introduced the execution of automated maintenance tasks during a maintenance
window. The automated tasks are statistics collection, segment advisor, and Automatic SQL Tuning.
With Oracle Database 11g, the Automated Maintenance Tasks feature relies on the Resource
Manager being enabled during the maintenance windows. Thus the resource plan associated with the
window is automatically enabled when the window opens. The goal is to prevent maintenance work
from consuming excessive amounts of system resources. Each maintenance window is associated
with a resource plan that specifies how the resources will be allocated during the window duration.
In Oracle Database 11g, WEEKNIGHT_WINDOW and WEEKEND_WINDOW (defined in Oracle
Database 10g) are replaced with daily maintenance windows. Automated tasks are assigned to
specific windows. All daily windows belong to MAINTENANCE_WINDOW_GROUP by default.
You are still completely free to define other maintenance windows as well as change start times and
durations for the daily maintenance windows. Likewise, any maintenance windows that are deemed
unnecessary can be disabled or removed. The operations can be done by using EM or Scheduler
interfaces.
NAME
--------------------------------
DEFAULT_MAINTENANCE_PLAN
Run Job1 Run Job2 Run Job3 Run Job3 Run Job4
with with with with with
urgent urgent high medium medium
priority priority priority priority priority
urgent MMON
Stats high
Maintenance medium
window ABP
Space
Job1 Jobn
SQL
DBA_AUTOTASK_TASK
OLTP DW/OLAP
(Small random I/O) (Large sequential I/O)
V$IOSTAT_FUNCTION
AWR and EM
.
V$IOSTAT_FILE
V$IOSTAT_CONSUMER_GROUP
Default Plan
The slide shows the properties of DEFAULT_PLAN. Note that there are no limits for its thresholds.
As you can see, Oracle Database 11g introduces two new I/O limits that you can define as thresholds
in a Resource Plan.
Regular job
Highest overhead
Best recovery
Most flexible
Persistent lightweight job
Less overhead
Some recovery
Limited change to attributes
END;
/
Self-diagnostic engine
Instance ADDM
AWR
Inst1 InstN
SGA_TARGET
PGA_AGGREGATE_TARGET:
Specifies the target aggregate amount of PGA memory
available to the instance
Can be dynamically modified at the instance level
Examples: 100,000 KB, 2,500 MB, 50 GB
Default: 10 MB or 20% of SGA size (whichever is greater)
WORKAREA_SIZE_POLICY:
Optional
Can be dynamically modified at the instance or session
level
Enables fallback to static SQL memory management for a
particular session
Free t arge
t
Free PGA target PGA
SQL areas
SQL areas
SQL areas
SGA targ
et Buffer cache
SGA target
Buffer cache
Buffer cache
Large pool
Large pool
SGA memory
Large pool
11g 11g
350 MB 350 MB
Memory Memory
max target max target
300 MB
Memory target
250 MB
Memory target
MEMORY_MAX_TARGET
SGA_MAX_SIZE
MEMORY_TARGET
SGA_TARGET PGA_AGGREGATE_TARGET
SHARED_POOL_SIZE
Others
DB_CACHE_SIZE
LARGE_POOL_SIZE
JAVA_POOL_SIZE
STREAMS_POOL_SIZE
DB_KEEP_CACHE_SIZE LOG_BUFFER
DB_RECYCLE_CACHE_SIZE RESULT_CACHE_SIZE
DB_nK_CACHE_SIZE
N
MT=0 MMT>0
Y
ST>0 & PAT>0 ST+PAT<=MT<=MMT
Y
MT can be N Minimum possible values
MT=0 dynamically
changed later. Y
ST>0 & PAT=0 PAT=MT-ST
Y
SGA and PGA N
ST>0 are separately
Y
auto-tuned. ST=0 & PAT>0 ST=min(MT-PAT,SMS)
N
Only PGA N
is auto-tuned.
ST=60%MT
SGA and PGA cannot PAT=40%MT
grow and shrink automatically.
Database level
Global level
CASCADE DEGREE
ESTIMATE_PERCENT METHOD_OPT
NO_INVALIDATE GRANULARITY
PUBLISH INCREMENTAL
STALE_PERCENT
set_global_prefs
DB
set_database_prefs MS
_S
se TA
t| TS
ex get |
set_schema_prefs po d
rt | ele
im te
po
set_table_prefs rt
gather_*_stats DBA
exec dbms_stats.set_table_prefs('SH','SALES','STALE_PERCENT','13');
Note: You can describe all the effective statistics preference settings for all relevant tables by using
the DBA_TAB_STAT_PREFS view.
Global
Q1 1970 Q2 1970 Q1 2007 Q1 1970 Q2 1970 Q1 2007 Q1 1970 Q2 1970 Q1 2007
statistics
S(MAKE MODEL)=S(MAKE)xS(MODEL)
select
dbms_stats.create_extended_stats('jfv','vehicle','(make,model)') from
dual; 2
exec dbms_stats.gather_table_stats('jfv','vehicle',-
method_opt=>'for all columns size 1 for columns (make,model) size 3'); 3
MAKE MODEL
4
S(MAKE MODEL)=S(MAKE,MODEL)
VEHICLE
MODEL
VEHICLE
MODEL Still possible
Recommended
VEHICLE DBA_STAT_EXTENSIONS
S(upper( MODEL))=0.01 MODEL
SYS_STU3FOQ$BDH0S_14NGXFJ3TQ50
OPTIMIZER_USE_PENDING_STATISTICS=FALSE
Dictionary
Pending statistics
statistics
PUBLISH=FALSE
+
GATHER_*_STATS
DBA_TAB_PENDING_STATS
IMPORT_TABLE_STATS
expdp/impdp
PUBLISH_PENDING_STATS
EXPORT_PENDING_STATS
TEST
exec dbms_stats.set_table_prefs('SH','CUSTOMERS','PUBLISH','false'); 1
exec dbms_stats.gather_table_stats('SH','CUSTOMERS'); 2
exec dbms_stats.publish_pending_stats('SH','CUSTOMERS'); 5
Oracle Partitioning
The slide summarizes the ten years of partitioning development at Oracle.
Note: REF partitioning enables pruning and partitionwise joins against child tables. While
performance seems to be the most visible improvement, do not forget about the rest. Partitioning
must address all business-relevant areas of performance, manageability, and availability.
Interval partitioning
System partitioning
Composite partitioning enhancements
Virtual column-based partitioning
Reference partitioning
Partitioning Enhancements
Partitioning is an important tool for managing large databases. Partitioning allows the DBA to
employ a divide and conquer methodology for managing database tables, especially as those tables
grow. Partitioned tables allow a database to scale for very large data sets while maintaining
consistent performance, without unduly impacting administrative or hardware resources.
Partitioning enables faster data access within an Oracle database. Whether a database has 10 GB or
10 TB of data, partitioning can speed up data access by orders of magnitude.
With the introduction of Oracle Database 11g, the DBA will find a useful assortment of partitioning
enhancements. These enhancements include:
Addition of interval partitioning
Addition of system partitioning
Composite partitioning enhancements
Addition of virtual column-based partitioning
Addition of reference partitioning
Interval Partitioning
Before the introduction of interval partitioning, the DBA was required to explicitly define the range
of values for each partition. The problem is explicitly defining the bounds for each partition does not
scale as the number of partitions grow.
Interval partitioning is an extension of range partitioning, which instructs the database to
automatically create partitions of a specified interval when data inserted into the table exceeds all of
the range partitions. You must specify at least one range partition. The range partitioning key value
determines the high value of the range partitions, which is called the transition point, and the
database creates interval partitions for data beyond that transition point.
Interval partitioning fully automates the creation of range partitions. Managing the creation of new
partitions can be a cumbersome and highly repetitive task. This is especially true for predictable
additions of partitions covering small ranges, such as adding new daily partitions. Interval
partitioning automates this operation by creating partitions on demand.
When using interval partitioning, consider the following restrictions:
You can specify only one partitioning key column, and it must be of NUMBER or DATE type.
Interval partitioning is not supported for index-organized tables.
You cannot create a domain index on an interval-partitioned table.
Automatically created
when you insert data
P1 P2 P3 Pi1 Pin
PREVIOUS
< 01/01/07 INSERT INTO orders_interval ();
Transition point
Not yet
PREVIOUS materialized SYS_Px SYS_Py SYS_Pz SYS_Pt
< 01/01/07 < 01/08/06 < 01/11/06 < 01/12/06 < 01/03/08
Transition point
System partitioning:
Enables application-controlled partitioning for selected
tables
Provides the benefits of partitioning but the partitioning
and data placement are controlled by the application
Does not employ partitioning keys like other
partitioning methods
Does not support partition pruning in the traditional
sense
System Partitioning
System partitioning enables application-controlled partitioning for arbitrary tables. This is mainly
useful when you develop your own partitioned domain indexes. The database simply provides the
ability to break down a table into meaningless partitions. All other aspects of partitioning are
controlled by the application. System partitioning provides the well-known benefits of partitioning
(scalability, availability, and manageability), but the partitioning and actual data placement are
controlled by the application.
The most fundamental difference between system partitioning and other methods is that system
partitioning does not have any partitioning keys. Consequently, the distribution or mapping of the
rows to a particular partition is not implicit. Instead, the user specifies the partition to which a row
maps by using partition-extended syntax when inserting a row.
Because system-partitioned tables do not have a partitioning key, the usual performance benefits of
partitioned tables are not available for system-partitioned tables. Specifically, there is no support for
traditional partition pruning, partitionwise joins, and so on. Partition pruning is achieved by
accessing the same partitions in the system-partitioned tables as those that were accessed in the base
table.
System-partitioned tables provide the manageability advantages of equipartitioning. For example, a
nested table can be created as a system-partitioned table that has the same number of partitions as the
base table. A domain index can be backed up by a system-partitioned table that has the same number
of partitions as the base table.
Oracle Database 11g: New Features for Administrators 9 - 8
System Partitioning: Example
Because of the peculiar requirements of system partitioning, the following operations are not
supported for system partitioning:
Unique local indexes are not supported because they require a partitioning key.
CREATE TABLE AS SELECT is not supported because there is no partitioning method. It is
not possible to distribute rows to partitions. Instead, you should first create the table and then
insert rows into each partition.
SPLIT PARTITION operations
Reference Partitioning
Reference partitioning provides the ability to partition a table based on the partitioning scheme of the
table referenced in its referential constraint. The partitioning key is resolved through an existing
parent/child relationship, which is enforced by active primary key or foreign key constraints. The
benefit of this is that tables with a parent/child relationship can be logically equipartitioned by
inheriting the partitioning key from the parent table without duplicating the key columns. The logical
dependency also automatically cascades partition maintenance operations, making application
development easier and less error prone.
Range(ORDER_DATE)
Primary key (ORDER_ID)
Table ORDERS
Table
ORDER_ITEMS
Range(ORDER_DATE)
Foreign key (ORDER_ID)
Interval-Hash
LIST, RANGE, HASH
Compressed
data
PCTFREE reached
triggers compression.
Uncompressed
data
Free
space
Inserts are
uncompressed.
What
partitions, indexes,
and MVs do I need SQL
to optimize Solution Access
my entire Advisor
workload?
DBA
No expertise
required Component
Workload
of CBO
Provides
implementation
script
SQL Access
Advisor
SQL cache
Workload
Hypothetical
STS
Filter
Options
Possible Recommendations
SQL Access Advisor carefully considers the overall impact of recommendations and makes
recommendations by using only the known workload and supplied information. Two workload
analysis methods are available:
Comprehensive: With this approach, SQL Access Advisor addresses all aspects of tuning
partitions, materialized views, indexes, and materialized view logs. It assumes that the workload
contains a complete and representative set of application SQL statements.
Limited: Unlike the comprehensive workload approach, a limited workload approach assumes
that the workload contains only problematic SQL statements. Thus, advice is sought for
improving the performance of a portion of an application environment.
When comprehensive workload analysis is chosen, SQL Access Advisor forms a better set of global
tuning adjustments, but the effect may be a longer analysis time. As shown in the table, the chosen
workload approach determines the type of recommendations made by the advisor.
Note: Partition recommendations can work on only those tables that have at least 10,000 rows, and
workloads that have some predicates and joins on columns of NUMBER or DATE type. Partitioning
advices can be generated only on these types of columns. In addition, partitioning advices can be
generated only for single-column interval and hash partitions. Interval partitioning recommendations
can be output as range syntax but interval is the default. Hash partitioning is done to leverage only
partitionwise joins.
Step 3
ADD_STS_REF
Step 1
DELETE_STS_REF
CREATE_TASK EXECUTE_TASK
UPDATE_TASK_ATTRIBUTES INTERRUPT/CANCEL_TASK
DELETE_TASK MARK_RECOMMENDATION
QUICK_TUNE UPDATE_REC_ATTRIBUTES
GET_TASK_REPORT
Task-dependent GET_TASK_SCRIPT
SQL
Access Advisor
Advisor-dependent task
Report/Scripts
SET_TASK_PARAMETER
RESET_TASK
Step 2
BEGIN 1
dbms_advisor.create_task(dbms_advisor.sqlaccess_advisor,'MYTASK');
END;
BEGIN
dbms_advisor.set_task_parameter('MYTASK','ANALYSIS_SCOPE','ALL');
2
dbms_advisor.set_task_parameter('MYTASK','MODE','COMPREHENSIVE');
END;
BEGIN 3
dbms_advisor.add_sts_ref('MYTASK','SH','MYSTS');
dbms_advisor.execute_task('MYTASK');
dbms_output.put_line(dbms_advisor.get_task_script('MYTASK'));
END;
Target
Data files database Image copies
Backup pieces
Change
Backup data
tracking
file
Flash Recovery Area
Optimized Backups
Increased Speed of Compression When Preserving Backup Space
You can use the CONFIGURE command to choose between the BZIP2 and ZLIB compression
algorithms for RMAN backups. The new ZLIB backup compression algorithm can be 40%
faster than the previous BZIP2 algorithm. The real-world data warehousing database from one
large pharmaceutical company had a compression ratio 2.0:1 with the BZIP2 algorithm, and
1.68:1 with the ZLIB algorithm. Configure the backup compression algorithm with the
following command (replace alg_name with either BZIP2 or ZLIB):
CONFIGURE COMPRESSION ALGORITHM TO 'alg_name';
Note: For more details, see the Oracle Database Backup and Recovery Reference.
Improved Block Corruption Detection
In addition to the RMAN-detected block corruptions, Oracle Database 11g also records live
block corruptions in the V$DATABASE_BLOCK_CORRUPTION view. The Oracle database
automatically updates this view when block corruptions are detected or repaired. The
VALIDATE command is enhanced with many new options such as VALIDATE ... BLOCK
and VALIDATE DATABASE.
Target
Data files database Image copies
Backup pieces
Archive X
log files
Redundant Backup data
archive log
files Flash Recovery Area
Channel 1
Section 1
Channel 2
Section 2
Channel 3
Section 3
Channel 4
Section 4
One large data file
Destination or
AUXILIARY database
TCP/IP
Duplicating a Database
Prior to Oracle Database 11g, you could create a duplicate database with RMAN for testing or
for standby. It required the source database, a copy of a backup on the destination system, and
the destination database itself.
Oracle Database 11g greatly simplifies this process. You can instruct the source database to
perform online image copies and archived log copies directly to the auxiliary instance, by using
Enterprise Manager or the FROM ACTIVE DATABASE clause of the RMAN DUPLICATE
command. Preexisting backups are no longer needed.
The database files are copied from the source to a destination or AUXILIARY instance via an
inter-instance network connection. RMAN then uses a memory script (one that is contained
only in memory) to complete recovery and open the database.
2 3