Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

How to capture a SQL workload in 11g

Oracle Tips by Burleson Consulting
March 3, 2008

 

Staring with Oracle 10g, Oracle introduced database replay  where you can avoid using artificial test data by grabbing real-world workloads.  This allows the DBA more flexibility than ever before, and increases the validity of pre-production testing.

Workload-based optimization is an important part of global SQL optimization, and Oracle codified the "holistic" approach to Oracle tuning, most directly in the 11g SQL Performance Analyzer, called "SPA".  See these related notes on workload-based testing:

 

Workload management is a major new approach for Oracle, away from contrived test cases, and into testing with empirical, real-world workloads. 

Capturing a workload

First, see 11g SQL Performance Analyzer tips for a detailed discussion of capturing a SQL tuning set.  Ahmed Baraka notes these steps in capturing a SQL workload in 11g:

Preparing to Capture a SQL Workload

Before you capture the workload, perform the following steps:

1. Backup database data that you want to test. Use either RMAN, user-managed online backup, Data Pump utilities or a snapshot standby. Output files of this backup will be used for the replay process.

2. Any transaction that is underway when you start capturing the workload may not be captured. If you want to capture all transactions, you can restart the database in restricted mode, start the capture process, then open the database for users.

3. Create directory object for storing captured workload.

Create directory WORKLOAD_DIR as 'C:\Oracle\admin\ora11g\workload';

4. Decide whether some of the user sessions should not be captured. You may not need to capture DBA sessions, Oracle Enterprise Manager sessions or any sessions created by third party sessions. To achieve this task, use DBMS_WORKLOAD_CAPTURE package as in the following guidelines:

a. Use ADD_FILTER procedure to add any eliminating sessions based on USER, MODULE, ACTION, PROGRAM, SERVICE or INSTANCE_NUMBER:

BEGIN
DBMS_WORKLOAD_CAPTURE.ADD_FILTER(
FNAME => 'FILTER_DBA1',
FATTRIBUTE => 'USER',
FVALUE => 'SYSTEM,DBSNMP' );
END;

b. Use DELETE_FILTER procedure to delete any existing filter:

EXEC DBMS_WORKLOAD_CAPTURE.DELETE_FILTER( FNAME => 'FILTER_DBA1');

Capturing a SQL Workload

Use START_CAPTURE procedure in DBMS_WORKLOAD_CAPTURE package to start capturing the workload:

BEGIN
DBMS_WORKLOAD_CAPTURE.START_CAPTURE(
NAME => '1JAN_WORKLOAD',
DIR => 'WORKLOAD_DIR',
DURATION => 40); -- duration in minutes
END;

 Stopping a SQL capture

To stop the capture process before ending of duration period, issue the following command:

BEGIN
DBMS_WORKLOAD_CAPTURE.FINISH_CAPTURE;
END;

Displaying a workload

After capture process finishes, you can issue query about workload captures using the following command:

SELECT
   ID,
   NAME,
   STATUS,
   ERROR_MESSAGE
FROM
    DBA_WORKLOAD_CAPTURES;

You can generate a report about the workload capture you have made:

DECLARE
v_capture_id number;
v_capture_rpt clob;

BEGIN

v_capture_id := DBMS_WORKLOAD_CAPTURE.GET_CAPTURE_INFO(DIR => 'WORKLOAD_DIR');

v_capture_rpt := DBMS_WORKLOAD_CAPTURE.REPORT( CAPTURE_ID => v_capture_id , FORMAT => DBMS_WORKLOAD_CAPTURE.TYPE_TEXT); -- format could also be TYPE_HTML

-- display contents of v_capture

END;

Alternatively, you can use the following statements:

SELECT
   id,
   name,
   status
FROM
   dba_workload_caprures؛

SELECT DBMS_WORKLOAD_CAPTURE.REPORT(1, 'HTML') FROM DUAL;

If you want to delete from its data dictionary views, used the procedure DELETE_CAPTURE_INFO.

However, this procedure does not delete the workload capture files in its directory. If you want to take a new workload capture with the same name, you should manually get rid of its files otherwise an error will be returned when you execute START_CAPTURE procedure.

Testing with your workloads

Just like a tape recorder, this create an encapsulated set of SQL statements that can be used to ?load down? our test database and make it behave as-if it was production.
 
Let's make an example, by investigating an optimizer_mode issue and examine the performance differences when running in all_rows ve running in first_rows_1 mode.
 
1 - Create a SQL Tuning Set (STS) (during a busy time of days)
 
2 ? Migrate the STS to the test database
 
3 ? Get the replay mechanism working
 
4 ? When in all_rows and again in first_rows_1, repeat these steps:
 
   5a ? Set the parameter
   5b ? Start running the STS
   5c -take an AWR report (several snapshots and reports)
  5d ? Upon completion, run plan9i.sql
  5e - For each case, analyze differences in the performance of the different optimizer modes

compare collected data

We then have the AWR report(s) and plan9i.sql output


See my related notes on Oracle workload techniques:

 

 

If you like Oracle tuning, you might enjoy my book "Oracle Tuning: The Definitive Reference", with 950 pages of tuning tips and scripts. 

You can buy it direct from the publisher for 30%-off and get instant access to the code depot of Oracle tuning scripts.


 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.