REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY...

74
REAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services Summary............................................................................................................................................................................ 3 Patches Required for RAT.................................................................................................................................................. 4 Project Implementation Steps............................................................................................................................................. 5 Clone production database on test server, start it up.........................................................................................................6 Create 11g database on test server on Windows............................................................................................................... 6 Download patches for RAT................................................................................................................................................. 6 Download RAT scripts and docs from OTN........................................................................................................................ 7 Patches Installation............................................................................................................................................................. 7 Install patch 6998002 on Windows 10g database.............................................................................................................. 9 Install patch 6903335 on Windows 10g clone database................................................................................................... 17 Install patch 7044721 on Windows 11g test database.....................................................................................................22 Configure and execute functional RAT tests on Windows................................................................................................ 36 Create A Small Test Inside To Clone Of Production To Test On Linux............................................................................ 36 Test Capture On The Production Clone...........................................................................................................................36 Create a filter for the session to capture........................................................................................................................... 38 Create a Directory to store the captured load................................................................................................................... 39 Start the Capture process................................................................................................................................................. 39 Stopping a Workload Capture..........................................................................................................................................41 Check capture process ID and status............................................................................................................................... 41 Exporting AWR Data for Workload Capture..................................................................................................................... 43 After completing the run gather awr statistics................................................................................................................... 45

Transcript of REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY...

Page 1: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

1/74

Alejandro VargasPrincipal Support Consultant

Oracle Advanced Customer Services

Summary............................................................................................................................................................................3Patches Required for RAT..................................................................................................................................................4Project Implementation Steps.............................................................................................................................................5Clone production database on test server, start it up.........................................................................................................6Create 11g database on test server on Windows...............................................................................................................6Download patches for RAT.................................................................................................................................................6Download RAT scripts and docs from OTN........................................................................................................................7

Patches Installation.............................................................................................................................................................7Install patch 6998002 on Windows 10g database..............................................................................................................9Install patch 6903335 on Windows 10g clone database...................................................................................................17Install patch 7044721 on Windows 11g test database.....................................................................................................22

Configure and execute functional RAT tests on Windows................................................................................................36Create A Small Test Inside To Clone Of Production To Test On Linux............................................................................36

Test Capture On The Production Clone...........................................................................................................................36Create a filter for the session to capture...........................................................................................................................38Create a Directory to store the captured load...................................................................................................................39Start the Capture process.................................................................................................................................................39Stopping a Workload Capture..........................................................................................................................................41Check capture process ID and status...............................................................................................................................41

Exporting AWR Data for Workload Capture.....................................................................................................................43After completing the run gather awr statistics...................................................................................................................45

Page 2: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

2/74

Generating a Workload Capture Report Using APIs........................................................................................................46

Workload Preprocessing..................................................................................................................................................47Workload Replay..............................................................................................................................................................47Steps for Replaying a Database Workload.......................................................................................................................50Prepare the Replay Database..........................................................................................................................................51Execute the Replay Database..........................................................................................................................................51

SQL Performance Analyzer..............................................................................................................................................55SQL Performance Analyzer Workflow Steps....................................................................................................................55Capture the SQL workload using API’s.............................................................................................................................55Create An Empty Sql Tuning Set To Be Populated With Some Load..............................................................................56Load SQL Statements on the STS...................................................................................................................................56Displaying the Contents of a SQL Tuning Set..................................................................................................................60Transporting a SQL Tuning Set........................................................................................................................................63Transport The Load Table To The Test System...............................................................................................................64FTP the table to the test system.......................................................................................................................................65Unpack the STS Into the Test System..............................................................................................................................68Prepare The Test System.................................................................................................................................................68Creating a SQL Performance Analyzer Task....................................................................................................................69Executing the SQL Workload Before a Change...............................................................................................................70Generate an Report with Analysis Of Task Results..........................................................................................................72

Page 3: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

3/74

Summary

This document is a step-by-step example of using Real Application Testing (RAT) to evaluate a platform migration of a10.2.0.3 production database from Windows 32bit to Linux 64 bit.

The project consider capturing and running production loads on a test environment using SQL Performance Analyzer(SPA) on a 10g production clone on Linux; and Database Replay on an production clone upgraded to 11g on Linux.

Both tests should provide information to evaluate if the Linux environment actual configuration is capable to sustain aproduction load.

The examples provided are limited, RAT offers a wide range of possible configurations, and this is an example of one ofthese multiple possibilities.

Complete information about RAT requirements for pre 11g databases can be found on Note 560977.1

Real Application Testing functionality for pre-11g database releases is installed using the “opatch” utility and followinginstructions for the generic and platform specific “README” for the patches. 11g do need also a patch to be able to useSQL traces from previous releases and create an SQL Tuning Set (STS).

Page 4: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

4/74

Patches Required for RAT

Here I’m relating only to the patches I did use on this test, a complete list of RAT required patches for variousplatforms could be found on Metalink on Note 560977.1.

If you want to only use Database Replay or SQL Performance Analyzer, then only the patch for that particularfunctionality needs to be applied. If you want to use both Database Replay and SQL Performance Analyzer, thepatches for both functionalities need to be applied.

Database Replay is only possible when using an 11g Database for the replay phase

Patches for Database Replay on Windows:Source Destination Patch10.2.0.3.0 32-bit >=11.1.0.6.0 10.2.0.3.0 + patch bundle 6998002 Available on Bundle 23.

Patches for Database Replay on Linux:Source Destination Patch10.2.0.3.0 >=11.1.0.6.0 10.2.0.3.0 + one off patch 6974999

Patch for SQL Performance Analyzer on WindowsSource Destination Patch10.2.0.3 10.2.0.4 i) 11.1.0.6 + 6865809(7044721) AND

ii) 10.2.0.3 + 6903335 ANDiii) 10.2.0.4 + 6877038

Download RAT documentation and scripts from

http://www.oracle.com/technology/software/products/database/oracle10g/realapptesting.html

Page 5: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

5/74

Project Implementation Steps

1. Clone production database on test server, start it up2. Create 11g database on test server on Windows3. Download patch 6998002 for Windows 32 bit4. Download patch 6903335 for Windows 32 bit5. Download patch 7044721 for 11.0.6.1 on windows6. Download patch 6974999 for 10.2.0.3 on Linux7. Download RAT scripts and docs from OTN8. Install patch 6998002 on Windows 10g clone database9. Install patch 6903335 on Windows 10g clone database10.Install patch 7044721 on Windows 11g test database11.Install patch 6974999 on Linux 10g test database12.Configure and execute functional RAT tests on Windows13.Install 11g on Linux14.Create 11g Database on Linux15.Migrate clone of production Database from windows to Linux16.Configure and execute functional RAT tests on Linux17.Install patch 6903335 on production database18.Capture load on production Database 19.Replay production load on Linux

Page 6: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

6/74

Clone production database on test server, start it up

Rman was used to create a clone of the production database on the test server.

Create 11g database on test server on Windows

11.1.0.6 was installed on the same test server where the 10g clone of production was created,

A new 11g database REALAPT was created

Download patches for RAT

RAT is available from 10.2.0.4 patch set. For previous releases is made available into one off patches, a completematrix of patches can be found on Metalink on Note 560977.1.

Patch 7044721 is required on 11.0.6.1 to be able to use SQL traces from previous releases and create an SQLTuning Set (STS) from them.

The following patches were downloaded and applied for this project:

Patch 6998002 for Windows 32 bitPatch 6903335 for Windows 32 bitPatch 7044721 for 11.0.6.1 on windowsPatch 6974999 for 10.2.0.3 on Linux

Page 7: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

7/74

Download RAT scripts and docs from OTN

RAT functionality can be run from Enterprise Manager or manually using the provided API’s.

Information about both approaches can be obtained from the 10g RAT user Guide that can be downloaded fromOTN.

The RAT user guide comes also as a part of the 11g manuals, can be downloaded from download.oracle.com.

Patches Installation

The patches required for enabling RAT on pre 11g versions and for the 11g version itself are installed usingopatch. A healthy inventory is required, and also you need to setup the path to opatch on the PATH environmentvariable.

The patch install is a little bit complex and each one do require several steps, check carefully the requisites as theyare different depending on the patch and the configuration, in general you will see these steps on most of them:

• Download • Install • run catcpu • Recompile with utlrp • recompile_precheck<version>• Shutdown • Startup upgrade • view_recompile_<version> • Shutdown

Page 8: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

8/74

• Startup • Recompile with utlrp

If you get from opatch errors related to the unavailability to copy some dll files, it is related to an Oracle executablestill running, to identify it use the command:

tasklist /m <dll name>

i.e.:

tasklist /m oran10.dll

It will show the program name and PID that is blocking it. You can shutdown this process and retry opatch apply.

Page 9: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

9/74

Install patch 6998002 on Windows 10g database

To install the patches prepare the environment to include the path to opatch

set ORACLE_HOME=c:\oracle\product\10.2.0\db_1set ORACLE_BASE=c:\oracleset ORACLE_SID=ORCLset PATH=c:\oracle\product\10.2.0\db_1\bin;C:\oracle\product\10.2.0\db_1\OPatch;C:\ProgramFiles\Oracle\jre\1.3.1\bin;C:\ProgramFiles\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDO WS;C:\WINDOWS\System32\Wbem;C:\Program Files\Windows Imaging

Shutdown the database and apply the patch:

C:\RAT-PATCHES\patch-6998002_10203_WINNT\6998002>opatch applyInvoking OPatch 10.2.0.3.0

Oracle interim Patch Installer version 10.2.0.3.0Copyright (c) 2005, Oracle Corporation. All rights reserved..

Oracle Home : c:\oracle\product\10.2.0\db_1Central Inventory : C:\Program Files\Oracle\Inventory

from : n/aOPatch version : 10.2.0.3.0OUI version : 10.2.0.3.0OUI location : c:\oracle\product\10.2.0\db_1\ouiLog file location : c:\oracle\product\10.2.0\db_1\cfgtoollogs\opatch\opatch2008-09-28_11-03-52AM.log

ApplySession applying interim patch '6998002' to OH 'c:\oracle\product\10.2.0\db_1'ApplySession: Optional component(s) [ oracle.rdbms.lbac, 10.2.0.3.0 ] , [ oracle.rdbms.dv,10.2.0.3.0 ] , [ oracle.ntoledb.odp_net_2, 10.2.0.2.20 ] , [ oracle.toledb, 10.2.0.2.20 ] ,[ oracle.oo4o, 10.2.0.2.20 ] , [ oracle.ntoramts, 10.2.0.3.0 ] , [ oracle.has.crs,

Page 10: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

10/74

10.2.0.3.0 ] , [ oracle.ldap.esm, 10.2.0.1.0 ] , [ oacle.precomp.lang, 10.2.0.3.0 ] , [oracle.rdbms.dv.oc4j, 10.2.0.3.0 ] , [ oracle.rdbms.ic, 10.2.0.3.0 ] not present in theOracle Home or a higher version is found.

Subset patches: 5071931

The fixes for Patch 5071931 are included in the patch currently being installed (6998002). If you continue, they will be rolled back and the new patch (699800) will be installed.

OPatch detected non-cluster Oracle Home from the inventory and will patch the local systemonly.

Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.(Oracle Home = 'c:\oracle\product\10.2.0\db_1')

Is the local system ready for patching?

Do you want to proceed? [y|n]yUser Responded with: YBacking up files and inventory (not for auto-rollback) for the Oracle HomeBacking up files affected by the patch '6998002' for restore. This might take a while...

Once opatch succeeded to apply the patch continue with the other required steps:

> cd %ORACLE_HOME%\BUNDLE\Patch23> sqlplus /nolog SQL> CONNECT / AS SYSDBA SQL> STARTUPSQL> @catcpu.sqlSQL> QUIT

Page 11: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

11/74

C:\oracle\product\10.2.0\db_1\BUNDLE\PATCH23>sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.3.0 - Production on Sun Sep 28 12:27:35 2008

Copyright (c) 1982, 2006, Oracle. All Rights Reserved.

Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> SELECT * FROM registry$history where ID = '6452863';

no rows selected <<<<<<<< means that we need to do view recompile

SQL> exitDisconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options

C:\oracle\product\10.2.0\db_1\BUNDLE\PATCH23>cd ..

C:\oracle\product\10.2.0\db_1\BUNDLE>dirVolume in drive C is C_LocalDiskVolume Serial Number is 7x99-xx66

Directory of C:\oracle\product\10.2.0\db_1\BUNDLE

09/28/2008 11:58 AM <DIR> .09/28/2008 11:58 AM <DIR> ..09/28/2008 12:03 PM <DIR> PATCH2309/28/2008 11:58 AM <DIR> view_recompile

0 File(s) 0 bytes4 Dir(s) 2,737,711,616 bytes free

Page 12: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

12/74

C:\oracle\product\10.2.0\db_1\BUNDLE>cd view_recompile

C:\oracle\product\10.2.0\db_1\BUNDLE\view_recompile>dirVolume in drive C is C_LocalDiskVolume Serial Number is 7x99-xx66

Directory of C:\oracle\product\10.2.0\db_1\BUNDLE\view_recompile

09/28/2008 11:58 AM <DIR> .09/28/2008 11:58 AM <DIR> ..03/19/2008 11:54 PM 2,089 recompile_precheck_jan2008cpu.sql03/19/2008 11:54 PM 5,140 view_recompile_jan2008cpu.sql

2 File(s) 7,229 bytes2 Dir(s) 2,737,711,616 bytes free

C:\oracle\product\10.2.0\db_1\BUNDLE\view_recompile>sqlplus "/ as sysdba"

SQL> @recompile_precheck_jan2008cpu.sql

Running precheck.sql...

Number of views to be recompiled :2404-----------------------------------------------------------------------

Number of objects to be recompiled :4906Please follow the README.txt instructions for running viewrecomp.sql

PL/SQL procedure successfully completed.

SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> startup upgrade

Page 13: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

13/74

ORACLE instance started.

Total System Global Area 2147483648 bytesFixed Size 1464608 bytesVariable Size 494757600 bytesDatabase Buffers 1635778560 bytesRedo Buffers 15482880 bytesDatabase mounted.Database opened.SQL> @@view_recompile_jan2008cpu.sql

PL/SQL procedure successfully completed.PL/SQL procedure successfully completed.PL/SQL procedure successfully completed.1 row created.Commit complete.

No. of Invalid Objects is :2228Please refer to README.html to for instructions on validating these objects

PL/SQL procedure successfully completed.

Logfile for the current viewrecomp.sql session is : vcomp_ORCL_28Sep2008_12_33_52.log

SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> startupORACLE instance started.

Total System Global Area 2147483648 bytesFixed Size 1464608 bytesVariable Size 494757600 bytes

Page 14: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

14/74

Database Buffers 1635778560 bytesRedo Buffers 15482880 bytesDatabase mounted.Database opened.SQL> @?/rdbms/admin/utlrp

TIMESTAMP--------------------------------------------------------------------------------COMP_TIMESTAMP UTLRP_BGN 2008-09-28 12:44:36

DOC> The following PL/SQL block invokes UTL_RECOMP to recompile invalidDOC> objects in the database. Recompilation time is proportional to theDOC> number of invalid objects in the database, so this command may takeDOC> a long time to execute on a database with a large number of invalidDOC> objects.DOC>DOC> Use the following queries to track recompilation progress:DOC>DOC> 1. Query returning the number of invalid objects remaining. ThisDOC> number should decrease with time.DOC> SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);DOC>DOC> 2. Query returning the number of objects compiled so far. This numberDOC> should increase with time.DOC> SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;DOC>DOC> This script automatically chooses serial or parallel recompilationDOC> based on the number of CPUs available (parameter cpu_count) multipliedDOC> by the number of threads per CPU (parameter parallel_threads_per_cpu).DOC> On RAC, this number is added across all RAC nodes.DOC>DOC> UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallelDOC> recompilation. Jobs are created without instance affinity so that theyDOC> can migrate across RAC nodes. Use the following queries to verify

Page 15: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

15/74

DOC> whether UTL_RECOMP jobs are being created and run correctly:DOC>DOC> 1. Query showing jobs created by UTL_RECOMPDOC> SELECT job_name FROM dba_scheduler_jobsDOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';DOC>DOC> 2. Query showing UTL_RECOMP jobs that are runningDOC> SELECT job_name FROM dba_scheduler_running_jobsDOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';DOC>#

PL/SQL procedure successfully completed.

TIMESTAMP--------------------------------------------------------------------------------COMP_TIMESTAMP UTLRP_END 2008-09-28 12:45:12

PL/SQL procedure successfully completed.

DOC> The following query reports the number of objects that have compiledDOC> with errors (objects that compile with errors have status set to 3 inDOC> obj$). If the number is higher than expected, please examine the errorDOC> messages reported with each object (using SHOW ERRORS) to see if theyDOC> point to system misconfiguration or resource constraints that must beDOC> fixed before attempting to recompile these objects.DOC>#

OBJECTS WITH ERRORS-------------------

257

DOC> The following query reports the number of errors caught during

Page 16: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

16/74

DOC> recompilation. If this number is non-zero, please query the errorDOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errorsDOC> are due to misconfiguration or resource constraints that must beDOC> fixed before objects can compile successfully.DOC>#

ERRORS DURING RECOMPILATION---------------------------

331

Invoking Ultra Search Install/Upgrade validation procedure VALIDATE_WKUltra Search VALIDATE_WK done with no error

PL/SQL procedure successfully completed.

In this case the invalid objects were related to some user applications and not relevant to RAT

This finish the patch installation process on 10g 10.2.0.3

Page 17: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

17/74

Install patch 6903335 on Windows 10g clone database

To install the patches prepare the environment to include the path to opatch

set ORACLE_HOME=c:\oracle\product\10.2.0\db_1set ORACLE_BASE=c:\oracleset ORACLE_SID=ORCLset PATH=c:\oracle\product\10.2.0\db_1\bin;C:\oracle\product\10.2.0\db_1\OPatch;C:\ProgramFiles\Oracle\jre\1.3.1\bin;C:\ProgramFiles\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDO WS;C:\WINDOWS\System32\Wbem;C:\Program Files\Windows Imaging

Shutdown the database and apply the patch:

C:\RAT-PATCHES\patch-6903335_10203_Windiows\6903335>opatch applyInvoking OPatch 10.2.0.3.0

Oracle interim Patch Installer version 10.2.0.3.0Copyright (c) 2005, Oracle Corporation. All rights reserved..

Oracle Home : c:\oracle\product\10.2.0\db_1Central Inventory : C:\Program Files\Oracle\Inventory

from : n/aOPatch version : 10.2.0.3.0OUI version : 10.2.0.3.0OUI location : c:\oracle\product\10.2.0\db_1\ouiLog file location : c:\oracle\product\10.2.0\db_1\cfgtoollogs\opatch\opatch2008-09-25_17-31-52PM.log

ApplySession applying interim patch '6903335' to OH 'c:\oracle\product\10.2.0\db_1'

Page 18: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

18/74

OPatch detected non-cluster Oracle Home from the inventory and will patch the local systemonly.

Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.(Oracle Home = 'c:\oracle\product\10.2.0\db_1')

Is the local system ready for patching?

Do you want to proceed? [y|n]yUser Responded with: YBacking up files and inventory (not for auto-rollback) for the Oracle HomeBacking up files affected by the patch '6903335' for restore. This might take a while...Backing up files affected by the patch '6903335' for rollback. This might take a while...

Patching component oracle.rdbms, 10.2.0.3.0...Copying file to "c:\oracle\product\10.2.0\db_1\rdbms\admin\prvtspao.plb"ApplySession adding interim patch '6903335' to inventory

Verifying the update...Inventory check OK: Patch ID 6903335 is registered in Oracle Home inventory with propermeta-data.Files check OK: Files from Patch ID 6903335 are present in Oracle Home.

The local system has been patched and can be restarted.

OPatch succeeded.

C:\RAT-PATCHES\patch-6903335_10203_Windiows\6903335>opatch lsinventoryInvoking OPatch 10.2.0.3.0

Oracle interim Patch Installer version 10.2.0.3.0Copyright (c) 2005, Oracle Corporation. All rights reserved..

Page 19: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

19/74

Oracle Home : c:\oracle\product\10.2.0\db_1Central Inventory : C:\Program Files\Oracle\Inventory

from : n/aOPatch version : 10.2.0.3.0OUI version : 10.2.0.3.0OUI location : c:\oracle\product\10.2.0\db_1\ouiLog file location : c:\oracle\product\10.2.0\db_1\cfgtoollogs\opatch\opatch2008-09-25_17-42-11PM.log

Lsinventory Output file location :c:\oracle\product\10.2.0\db_1\cfgtoollogs\opatch\lsinv\lsinventory2008-09-25_17-42-11PM.txt

--------------------------------------------------------------------------------Installed Top-level Products (4):

Oracle Database 10g 10.2.0.1.0Oracle Database 10g Products 10.2.0.1.0Oracle Database 10g Release 2 Patch Set 1 10.2.0.2.0Oracle Database 10g Release 2 Patch Set 2 10.2.0.3.0There are 4 products installed in this Oracle Home.

Interim patches (3) :

Patch 6903335 : applied on Thu Sep 25 17:32:06 IDT 2008Created on 12 May 2008, 08:56:41 hrs US/PacificBugs fixed:

6903335

Patch 5071931 : applied on Sun Mar 16 15:17:14 IST 2008Created on 2 May 2007, 07:29:31 hrs PST8PDTBugs fixed:

Page 20: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

20/74

5071931

Patch 5746875 : applied on Thu Feb 07 14:08:45 IST 2008Created on 28 Feb 2007, 07:19:02 hrs US/EasternBugs fixed:

5126270, 5726033, 5746875

--------------------------------------------------------------------------------

OPatch succeeded.

Once patch 6903335 is successfully installed the following actions needs to be implemented

Patch Special Instructions:---------------------------cd $OH/rdbms/adminsqlplus / as sysdbadrop table plan_table$; -- drop the plan table if was upgraded. @catplan.sql -- recreate the plan table @dbmsxpln.sql -- reload dbms_xplan [email protected] -- reload dbms_xplan [email protected] -- reload dbms_sqlpa

If the Oracle inventory is not setup correctly this utility willfail. To check accessibility to the inventory you can use thecommand

The execution of prvtspao.plb failed to compile DBMS_SQLPA, you can see the errors on thefollowing log, the solution was available from Note 605317.1 and 565600.1 that actuallysolved the problem: drop plan_table$ and plan_table before retrying prvtspao.plb

SQL> @?/rdbms/admin/prvtspao.plb

Page 21: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

21/74

PL/SQL procedure successfully completed.Package created.No errors.Synonym created.No errors.Warning: Package Body created with compilation errors.Errors for PACKAGE BODY DBMS_SQLPA:LINE/COL ERROR-------- ------------------------------------------------------123/5 PL/SQL: SQL Statement ignored129/44 PL/SQL: ORA-00904: "OTHER_XML": invalid identifierSQL> alter package DBMS_SQLPA compile body;Warning: Package Body altered with compilation errors.

SQL> show errErrors for PACKAGE BODY DBMS_SQLPA:

LINE/COL ERROR-------- ------------------------------------------------------123/5 PL/SQL: SQL Statement ignored129/44 PL/SQL: ORA-00904: "OTHER_XML": invalid identifier

This finish the patch installation process on 10g 10.2.0.3

Page 22: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

22/74

Install patch 7044721 on Windows 11g test database

Setup the environment to 11g

set ORACLE_HOME=D:\ORACLE\11g\db11gset ORACLE_BASE=D:\ORACLE\11gset ORACLE_SID=REALAPTset PATH=D:\ORACLE\11g\db11g\bin;D:\ORACLE\11g\db11g\OPatch;C:\ProgramFiles\Oracle\jre\1.3.1\bin;C:\ProgramFiles\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;

Shutdown all resources running on the 11g home and execute opatch apply from the patch directory

C:\RAT-PATCHES\patch-7044721_111060_WINNT\7044721>opatch applyFile Not FoundInvoking OPatch 11.1.0.6.0

Oracle Interim Patch Installer version 11.1.0.6.0Copyright (c) 2007, Oracle Corporation. All rights reserved.

Oracle Home : D:\ORACLE\11g\db11gCentral Inventory : C:\Program Files\Oracle\Inventory

from : n/aOPatch version : 11.1.0.6.0OUI version : 11.1.0.6.0OUI location : D:\ORACLE\11g\db11g\ouiLog file location : D:\ORACLE\11g\db11g\cfgtoollogs\opatch\opatch2008-09-25_18-14-23PM.log

ApplySession applying interim patch '7044721' to OH 'D:\ORACLE\11g\db11g'

Running prerequisite checks...

Page 23: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

23/74

Patch 7044721: Optional component(s) missing : [ oracle.rdbms.ic, 11.1.0.6.0 ] , [oracle.rdbms.tg4msql, 11.1.0.6.0 ] , [ oracle.sysman.agent, 11.1.0.6.0 ] , [oracle.ntoledb.odp_net, 11.1.0.6.20 ] , [ oracle.ntoledb.odp_net_2, 11.1.0.6.20 ]

OPatch detected non-cluster Oracle Home from the inventory and will patch the local systemonly.

Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.(Oracle Home = 'D:\ORACLE\11g\db11g')

Is the local system ready for patching? [y|n]yUser Responded with: YBacking up files and inventory (not for auto-rollback) for the Oracle HomeBacking up files affected by the patch '7044721' for restore. This might take a while...Backing up files affected by the patch '7044721' for rollback. This might take a while...Execution of 'cmd /C "C:\RAT-PATCHES\patch-7044721_111060_WINNT\7044721\custom\scripts\pre.bat" -apply 7044721 ':

Return Code = 0

Patching component oracle.rdbms.rsf, 11.1.0.6.0...Copying file to "D:\ORACLE\11g\db11g\bin\oraclient11.dll"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\oraclient11.sym"Copying file to "D:\ORACLE\11g\db11g\bin\orageneric11.dll"Copying file to "D:\ORACLE\11g\db11g\bin\orapls11.dll"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\orageneric11.sym"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\orapls11.sym"Copying file to "D:\ORACLE\11g\db11g\lib\orapls11.lib"Copying file to "D:\ORACLE\11g\db11g\plsql\mesg\plwus.msb"

Patching component oracle.rdbms, 11.1.0.6.0...Updating jar file "D:\ORACLE\11g\db11g\rdbms\jlib\CDC.jar" with"\rdbms\jlib\CDC.jar\oracle\CDC\AdvanceChangeSet.class"

Page 24: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

24/74

Copying file to "D:\ORACLE\11g\db11g\bin\oracle.exe"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\oracle.sym"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\catplan.sql"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\dbmsspa.sql"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\dbmssqlt.sql"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\dbmssqlu.sql"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\dbmsxpln.sql"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvsspai.plb"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvssqli.plb"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvtxpln.plb"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvsadv.plb"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvtadv.plb"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvtdadv.plb"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvtspa.plb"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvtspai.plb"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvtsqlu.plb"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvtsqli.plb"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\prvtsqlt.plb"Copying file to "D:\ORACLE\11g\db11g\Bundle\view_recompile\view_recompile_bundlepatch4.sql"Copying file to"D:\ORACLE\11g\db11g\Bundle\view_recompile\recompile_precheck_bundlepatch4.sql"Copying file to "D:\ORACLE\11g\db11g\Bundle\Patch4\catcpu.sql"Copying file to "D:\ORACLE\11g\db11g\Bundle\Patch4\catcpu_rollback.sql"Copying file to "D:\ORACLE\11g\db11g\Bundle\Patch4\sdocpu.sql"Copying file to "D:\ORACLE\11g\db11g\Bundle\Patch4\javcpu.sql"

Patching component oracle.oracore.rsf, 11.1.0.6.0...Copying file to "D:\ORACLE\11g\db11g\bin\oracore11.dll"Copying file to "D:\ORACLE\11g\db11g\rdbms\admin\oracore11.sym"Copying file to "D:\ORACLE\11g\db11g\lib\oracore11.lib"

Patching component oracle.sdo.locator, 11.1.0.6.0...Copying file to "D:\ORACLE\11g\db11g\md\admin\prvtpidx.plb"

Page 25: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

25/74

Patching component oracle.ons, 11.1.0.5.0...Copying file to "D:\ORACLE\11g\db11g\opmn\bin\ons.exe"

Patching component oracle.rdbms.rsf.ic, 11.1.0.6.0...Copying file to "D:\ORACLE\11g\db11g\bin\oci.dll"

Patching component oracle.rdbms.oci, 11.1.0.6.0...Copying file to "D:\ORACLE\11g\db11g\oci\lib\msvc\oci.lib"

Patching component oracle.rdbms.hsodbc, 11.1.0.6.0...Copying file to "D:\ORACLE\11g\db11g\bin\dg4odbc.exe"ApplySession adding interim patch '7044721' to inventory

Verifying the update...Inventory check OK: Patch ID 7044721 is registered in Oracle Home inventory with propermeta-data.Files check OK: Files from Patch ID 7044721 are present in Oracle Home.

--------------------------------------------------------------------------------********************************************************************************** ATTENTION **** **** Please note that the Patch Installation (Patch Deinstallation) is not **** complete until all the Post Installation (Post Deinstallation) **** instructions noted in the Readme accompanying this patch, have been **** successfully completed. **** ******************************************************************************************************************************************************************--------------------------------------------------------------------------------

Execution of 'cmd /C "C:\RAT-PATCHES\patch-7044721_111060_WINNT\7044721\custom\scripts\post.bat" -apply 7044721 ':

Page 26: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

26/74

Return Code = 0

The local system has been patched and can be restarted.

OPatch succeeded.

After the patch the script catcpu located on directory $ORACLE_HOME\ Bundle\Patch4 needs to beexecuted

D:\ORACLE\11g\db11g\Bundle\Patch4>sqlplus / as sysdba

SQL> @catcpu.sql

Session altered.Session altered.PL/SQL procedure successfully completed.TIMESTAMP--------------------------------------------------------------------------------COMP_TIMESTAMP CPU_BGN 2008-09-25 18:29:45

PL/SQL procedure successfully completed.

Library created.No errors.Library created.Package created.No errors....... (more output)...TIMESTAMP--------------------------------------------------------------------------------COMP_TIMESTAMP SDO 2008-09-25 18:30:30DBUA_TIMESTAMP SDO VALID 2008-09-25 18:30:30

Page 27: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

27/74

0 rows deleted.1 row created.PL/SQL procedure successfully completed.

TIMESTAMP--------------------------------------------------------------------------------COMP_TIMESTAMP CPU_END 2008-09-25 18:30:30

No. of Invalid Objects is :28Please refer to README.html to for instructions on validating these objects

PL/SQL procedure successfully completed.

Logfile for the current catcpu.sql session is : APPLY_REALAPT_25Sep2008_18_29_45.logSQL> SELECT OBJECT_NAME FROM DBA_OBJECTS WHERE STATUS = 'INVALID';

OBJECT_NAME--------------------------------------------------------------------------------DBA_HIST_SQLBINDDBA_HIST_SQLBINDDBA_SQLSET_BINDSUSER_SQLSET_BINDSUSER_SQLSET_BINDSALL_SQLSET_BINDSALL_SQLSET_BINDSPRVT_REPORT_TAGSPRVT_SQLADV_INFRAPRVT_SQLSET_INFRAPRVT_SQLPROF_INFRADBMS_MANAGEMENT_PACKSPRVT_HDMWRI$_ADV_HDM_TDBMS_UNDO_ADV

Page 28: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

28/74

DBMS_SPMDBMS_SMB_INTERNALDBMS_SMBPRVT_WORKLOAD_NOPRIVWRI$_ADV_SQLACCESS_ADVWRI$_ADV_TUNEMVIEW_ADVPRVT_PARTREC_NOPRIVDBMS_XPLANDBMS_STATS_INTERNALDBMS_SQLDIAG_INTERNALDBMS_SQLTCB_INTERNALDBMS_SQLDIAGDBMS_CUBE_ADVISE

28 rows selected.

SQL> @?/rdbms/admin/utlrp

TIMESTAMP--------------------------------------------------------------------------------COMP_TIMESTAMP UTLRP_BGN 2008-09-25 18:37:53

DOC> The following PL/SQL block invokes UTL_RECOMP to recompile invalidDOC> objects in the database. Recompilation time is proportional to theDOC> number of invalid objects in the database, so this command may takeDOC> a long time to execute on a database with a large number of invalidDOC> objects.DOC>DOC> Use the following queries to track recompilation progress:DOC>DOC> 1. Query returning the number of invalid objects remaining. ThisDOC> number should decrease with time.DOC> SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);DOC>

Page 29: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

29/74

DOC> 2. Query returning the number of objects compiled so far. This numberDOC> should increase with time.DOC> SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;DOC>DOC> This script automatically chooses serial or parallel recompilationDOC> based on the number of CPUs available (parameter cpu_count) multipliedDOC> by the number of threads per CPU (parameter parallel_threads_per_cpu).DOC> On RAC, this number is added across all RAC nodes.DOC>DOC> UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallelDOC> recompilation. Jobs are created without instance affinity so that theyDOC> can migrate across RAC nodes. Use the following queries to verifyDOC> whether UTL_RECOMP jobs are being created and run correctly:DOC>DOC> 1. Query showing jobs created by UTL_RECOMPDOC> SELECT job_name FROM dba_scheduler_jobsDOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';DOC>DOC> 2. Query showing UTL_RECOMP jobs that are runningDOC> SELECT job_name FROM dba_scheduler_running_jobsDOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';DOC>#

PL/SQL procedure successfully completed.

TIMESTAMP--------------------------------------------------------------------------------COMP_TIMESTAMP UTLRP_END 2008-09-25 18:38:21

PL/SQL procedure successfully completed.

DOC> The following query reports the number of objects that have compiled

Page 30: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

30/74

DOC> with errors (objects that compile with errors have status set to 3 inDOC> obj$). If the number is higher than expected, please examine the errorDOC> messages reported with each object (using SHOW ERRORS) to see if theyDOC> point to system misconfiguration or resource constraints that must beDOC> fixed before attempting to recompile these objects.DOC>#

OBJECTS WITH ERRORS-------------------

0

DOC> The following query reports the number of errors caught duringDOC> recompilation. If this number is non-zero, please query the errorDOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errorsDOC> are due to misconfiguration or resource constraints that must beDOC> fixed before objects can compile successfully.DOC>#

ERRORS DURING RECOMPILATION---------------------------

0

PL/SQL procedure successfully completed.

Invoking Ultra Search Install/Upgrade validation procedure VALIDATE_WKUltra Search VALIDATE_WK done with no error

PL/SQL procedure successfully completed.

SQL> SELECT OBJECT_NAME FROM DBA_OBJECTS WHERE STATUS = 'INVALID';no rows selected

Page 31: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

31/74

After that need to check if view recompilation was done, this select should return one row, if not performview recompilation

SQL> SELECT * FROM registry$history where ID = '6452863';no rows selectedexit

cd D:\ORACLE\11g\db11g\Bundle\view_recompileD:\ORACLE\11g\db11g\Bundle\view_recompile>sqlplus / as sysdba

SQL> @recompile_precheck_bundlepatch4.sqlRunning precheck.sql...Number of views to be recompiled :2733-----------------------------------------------------------------------Number of objects to be recompiled :5543Please follow the README.txt instructions for running viewrecomp.sqlPL/SQL procedure successfully completed.

SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.

SQL> startup upgradeORACLE instance started.

Total System Global Area 292933632 bytesFixed Size 1332752 bytesVariable Size 226494960 bytesDatabase Buffers 58720256 bytesRedo Buffers 6385664 bytesDatabase mounted.Database opened.

Page 32: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

32/74

SQL> @view_recompile_bundlepatch4.sqlPL/SQL procedure successfully completed.PL/SQL procedure successfully completed.PL/SQL procedure successfully completed.

1 row created.

Commit complete.

No. of Invalid Objects is :33Please refer to README.html to for instructions on validating these objects

PL/SQL procedure successfully completed.Logfile for the current viewrecomp.sql session is : vcomp_REALAPT_28Sep2008_09_26_40.log

SQL> @?/rdbms/admin/utlrp

TIMESTAMP--------------------------------------------------------------------------------COMP_TIMESTAMP UTLRP_BGN 2008-09-28 09:31:05

DOC> The following PL/SQL block invokes UTL_RECOMP to recompile invalidDOC> objects in the database. Recompilation time is proportional to theDOC> number of invalid objects in the database, so this command may takeDOC> a long time to execute on a database with a large number of invalidDOC> objects.DOC>DOC> Use the following queries to track recompilation progress:DOC>DOC> 1. Query returning the number of invalid objects remaining. ThisDOC> number should decrease with time.DOC> SELECT COUNT(*) FROM obj$ WHERE status IN (4, 5, 6);DOC>

Page 33: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

33/74

DOC> 2. Query returning the number of objects compiled so far. This numberDOC> should increase with time.DOC> SELECT COUNT(*) FROM UTL_RECOMP_COMPILED;DOC>DOC> This script automatically chooses serial or parallel recompilationDOC> based on the number of CPUs available (parameter cpu_count) multipliedDOC> by the number of threads per CPU (parameter parallel_threads_per_cpu).DOC> On RAC, this number is added across all RAC nodes.DOC>DOC> UTL_RECOMP uses DBMS_SCHEDULER to create jobs for parallelDOC> recompilation. Jobs are created without instance affinity so that theyDOC> can migrate across RAC nodes. Use the following queries to verifyDOC> whether UTL_RECOMP jobs are being created and run correctly:DOC>DOC> 1. Query showing jobs created by UTL_RECOMPDOC> SELECT job_name FROM dba_scheduler_jobsDOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';DOC>DOC> 2. Query showing UTL_RECOMP jobs that are runningDOC> SELECT job_name FROM dba_scheduler_running_jobsDOC> WHERE job_name like 'UTL_RECOMP_SLAVE_%';DOC>#

PL/SQL procedure successfully completed.

TIMESTAMP--------------------------------------------------------------------------------COMP_TIMESTAMP UTLRP_END 2008-09-28 09:31:33

PL/SQL procedure successfully completed.

DOC> The following query reports the number of objects that have compiled

Page 34: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

34/74

DOC> with errors (objects that compile with errors have status set to 3 inDOC> obj$). If the number is higher than expected, please examine the errorDOC> messages reported with each object (using SHOW ERRORS) to see if theyDOC> point to system misconfiguration or resource constraints that must beDOC> fixed before attempting to recompile these objects.DOC>#

OBJECTS WITH ERRORS-------------------

0

DOC> The following query reports the number of errors caught duringDOC> recompilation. If this number is non-zero, please query the errorDOC> messages in the table UTL_RECOMP_ERRORS to see if any of these errorsDOC> are due to misconfiguration or resource constraints that must beDOC> fixed before objects can compile successfully.DOC>#

ERRORS DURING RECOMPILATION---------------------------

0

PL/SQL procedure successfully completed.

Invoking Ultra Search Install/Upgrade validation procedure VALIDATE_WKUltra Search VALIDATE_WK done with no error

PL/SQL procedure successfully completed.

SQL>SQL> shutdown immediateDatabase closed.Database dismounted.

Page 35: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

35/74

ORACLE instance shut down.SQL> startupORACLE instance started.

Total System Global Area 292933632 bytesFixed Size 1332752 bytesVariable Size 226494960 bytesDatabase Buffers 58720256 bytesRedo Buffers 6385664 bytesDatabase mounted.Database opened.SQL>

This finish the patch installation process on 11g 11.1.0.6

Page 36: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

36/74

Configure and execute functional RAT tests on Windows

Create A Small Test Inside To Clone Of Production To Test On Linux

>sqlplus "/ as sysdba"

SQL> create tablespace avtest datafile 'E:\ORACLE\ORADATA\ORCL\AVTST_01_TBS.DBF' size 100m;Tablespace created.

SQL> create user avargas identified by oracle default tablespace avtest temporary tablespacetemp;User created.

SQL> grant dba , all privileges to avargas;Grant succeeded.

SQL> connect avargas/oracleConnected.SQL> create table test1 as select * from dba_source;Table created.

SQL> create table test2 as select * from dba_users;Table created.

Test Capture On The Production Clone

Parameter PRE_11G_ENABLE_CAPTURE=TRUE is required only on 10.2.0.4 lower releases do not need to setit.

Page 37: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

37/74

Before capturing the database may be restarted to assure all transactions are captured, otherwise uncommittedtransactions may be left out of the captured load.

Workload Capture Restrictions

The following types of client requests are not captured in a workload in the current release:

• Direct path load of data from external files using utilities such as SQL*Loader• Shared server requests (Oracle MTS)• Oracle Streams• Advanced Replication streams• Non-PL/SQL based Advanced Queuing (AQ)• Flashback queries• Oracle Call Interface (OCI) based object navigations• Non SQL-based object access• Distributed transactions (any distributed transactions that are captured will be

replayed as local transactions)• Remote DESCRIBE and COMMIT operations

Using Database Replay requires four main steps

• Workload Capture• Workload Preprocessing• Workload Replay• Analysis and Reporting

Capturing a Database Workload Using APIs

Capturing a database workload using the DBMS_WORKLOAD_CAPTURE package involves:

Page 38: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

38/74

• Adding and Removing Workload Filters• Starting a Workload Capture• Stopping a Workload Capture• Exporting AWR Data for Workload Capture

Create a filter for the session to capture

BEGINDBMS_WORKLOAD_CAPTURE.ADD_FILTER (

fname => 'user_avargas',fattribute => 'USER',fvalue => 'AVARGAS');

END;/

SQL> BEGIN2 DBMS_WORKLOAD_CAPTURE.ADD_FILTER (3 fname => 'user_avargas',4 fattribute => 'USER',5 fvalue => 'AVARGAS');6 END;7 /

PL/SQL procedure successfully completed.

To disable the filter can use:

BEGINDBMS_WORKLOAD_CAPTURE.DELETE_FILTER (fname => 'AVARGAS');

END;/

Page 39: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

39/74

Create a Directory to store the captured load

SQL> create or replace directory loadcapt as 'E:\RAT_LOAD_CAPTURE';Directory created.

SQL> grant read , write on directory loadcapt to public;Grant succeeded.

Start the Capture process

BEGINDBMS_WORKLOAD_CAPTURE.START_CAPTURE (name => 'ORCL Test Capture',

dir => 'LOADCAPT',duration => 600);

END;/

SQL> BEGIN2 DBMS_WORKLOAD_CAPTURE.START_CAPTURE (name => 'ORCL Test Capture',3 dir => 'LOADCAPT',4 duration => 600);5 END;6 /

PL/SQL procedure successfully completed.

In this example the filter previously created is considered an exclusion filter, user avargas is excluded fromthe capture.

Page 40: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

40/74

To use it as an inclusion filter for the user defined on it add the parameter "default_action => EXCLUDE" thatindicates to exclude all users except the user or users included in a defined filter.

The default action used is INCLUDE, if not defined will be used and any defined user on a filter will be excluded.

BEGINDBMS_WORKLOAD_CAPTURE.START_CAPTURE (name => 'ORCL Test Capture 2',

dir => 'LOADCAPT',duration => 600,default_action => 'EXCLUDE');

END;/

Make some load as avargas

SQL> delete from test1 where substr(name,1,10)='MMS_TIPUL_';26740 rows deleted.

SQL> commit;Commit complete.

SQL> delete from test1 where substr(name,1,10)='MRK_PIZUR_';23849 rows deleted.

SQL> commit;Commit complete.

SQL> delete from test1 where substr(name,1,5)like 'MGMT';0 rows deleted.

SQL> delete from test1 where substr(name,1,5)like 'MGMT_';62217 rows deleted.

Page 41: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

41/74

SQL> rollback;Rollback complete.SQL> delete from test1 where substr(name,1,5)like 'MGMT_';62217 rows deleted.

SQL> commit;Commit complete.

Stopping a Workload Capture

To stop the workload capture, use the FINISH_CAPTURE procedure:

BEGINDBMS_WORKLOAD_CAPTURE.FINISH_CAPTURE ();

END;/

SQL> BEGIN2 DBMS_WORKLOAD_CAPTURE.FINISH_CAPTURE ();3 END;4 /

PL/SQL procedure successfully completed.

Check capture process ID and status

COL NAME FOR A25COL DIRECTORY FOR A15COL STATUS FOR A20SELECT ID,NAME,DIRECTORY,STATUS FROM DBA_WORKLOAD_CAPTURES/

Page 42: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

42/74

SQL> COL NAME FOR A25SQL> COL DIRECTORY FOR A15SQL> COL STATUS FOR A20

SQL> SELECT ID,NAME,DIRECTORY,STATUS FROM DBA_WORKLOAD_CAPTURES/

ID NAME DIRECTORY STATUS---------- ------------------------- --------------- --------------------

1 ORCL Test Capture LOADCAPT COMPLETED

After second run

SQL> COL NAME FOR A25SQL> COL DIRECTORY FOR A15SQL> COL STATUS FOR A20SQL> SELECT ID,NAME,DIRECTORY,STATUS FROM DBA_WORKLOAD_CAPTURES

2 /

ID NAME DIRECTORY STATUS---------- ------------------------- --------------- --------------------

1 ORCL Test Capture LOADCAPT COMPLETED3 ORCL Test Capture 2 LOADCAPT COMPLETED

Page 43: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

43/74

Exporting AWR Data for Workload Capture

Exporting AWR data enables detailed analysis of the workload. This data is also required if you plan to run theAWR Compare Period report on a pair of workload captures or replays.

To export AWR data, use the EXPORT_AWR procedure:

BEGINDBMS_WORKLOAD_CAPTURE.EXPORT_AWR (capture_id => 3);

END;/

SQL> BEGIN2 DBMS_WORKLOAD_CAPTURE.EXPORT_AWR (capture_id => 1);3 END;4 /

PL/SQL procedure successfully completed.

Check the Capture process directory and files

E:\ >CD E:\RAT_LOAD_CAPTURE

E:\RAT_LOAD_CAPTURE>dirVolume in drive E is New VolumeVolume Serial Number is 9870-7791

Directory of E:\RAT_LOAD_CAPTURE

09/28/2008 03:30 PM <DIR> .09/28/2008 03:30 PM <DIR> ..

Page 44: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

44/74

09/28/2008 03:21 PM 1,112 wcr_4jrvp5w0021m8.rec09/28/2008 03:14 PM 1,125 wcr_4jrvp5w0025us.rec09/28/2008 03:22 PM 1,400 wcr_4jrvqsn0024yw.rec09/28/2008 03:42 PM 1,586,958,336 WCR_CA.DMP09/28/2008 03:42 PM 29,543 wcr_ca.log09/28/2008 03:22 PM 39,070 wcr_cr.html09/28/2008 03:22 PM 19,720 wcr_cr.text09/28/2008 03:22 PM 199 wcr_fcapture.wmd09/28/2008 03:14 PM 134 wcr_scapture.wmd

9 File(s) 1,587,050,639 bytes2 Dir(s) 4,089,331,712 bytes free

The same directory after having removed the previous files and run the 2nd Capture

E:\RAT_LOAD_CAPTURE>dirVolume in drive E is New VolumeVolume Serial Number is 9870-7791

Directory of E:\RAT_LOAD_CAPTURE

09/28/2008 04:09 PM <DIR> .09/28/2008 04:09 PM <DIR> ..09/28/2008 04:03 PM 741 wcr_4jrw0r800207c.rec09/28/2008 04:08 PM 33,280 wcr_4jrw0sc00258n.rec09/28/2008 04:04 PM 733 wcr_4jrw0y0002074.rec09/28/2008 04:04 PM 733 wcr_4jrw0y00020mw.rec09/28/2008 04:04 PM 733 wcr_4jrw0y00020t0.rec09/28/2008 04:04 PM 734 wcr_4jrw0y00021zc.rec09/28/2008 04:04 PM 734 wcr_4jrw0y000248s.rec09/28/2008 04:04 PM 734 wcr_4jrw0y00024q8.rec09/28/2008 04:04 PM 734 wcr_4jrw0y00024rs.rec09/28/2008 04:04 PM 733 wcr_4jrw0y00025j4.rec09/28/2008 04:04 PM 733 wcr_4jrw0y00025r0.rec09/28/2008 04:04 PM 67 wcr_4jrw0yc0020nh.rec

Page 45: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

45/74

09/28/2008 04:04 PM 68 wcr_4jrw0yc00225c.rec09/28/2008 04:04 PM 68 wcr_4jrw0yc0024bh.rec09/28/2008 04:05 PM 68 wcr_4jrw15w0021z0.rec09/28/2008 04:05 PM 68 wcr_4jrw15w0024a4.rec09/28/2008 04:05 PM 68 wcr_4jrw15w0024rn.rec09/28/2008 04:06 PM 68 wcr_4jrw1dc0021zn.rec09/28/2008 04:06 PM 68 wcr_4jrw1dc0022q0.rec09/28/2008 04:06 PM 68 wcr_4jrw1dc0024qh.rec09/28/2008 04:07 PM 68 wcr_4jrw1nw002100.rec09/28/2008 04:07 PM 68 wcr_4jrw1nw0024n0.rec09/28/2008 04:07 PM 68 wcr_4jrw1nw0025sn.rec09/28/2008 04:08 PM 67 wcr_4jrw1wc0020p4.rec09/28/2008 04:08 PM 68 wcr_4jrw1wc0021bh.rec09/28/2008 04:08 PM 68 wcr_4jrw1wc0025yc.rec09/28/2008 04:09 PM 983 wcr_4jrw1zc0022sh.rec09/28/2008 04:09 PM 38,582 wcr_cr.html09/28/2008 04:09 PM 19,376 wcr_cr.text09/28/2008 04:09 PM 203 wcr_fcapture.wmd09/28/2008 04:03 PM 136 wcr_scapture.wmd

31 File(s) 100,920 bytes2 Dir(s) 5,676,171,264 bytes free

After completing the run gather awr statistics

BEGINDBMS_WORKLOAD_CAPTURE.EXPORT_AWR (capture_id => 3);

END;/

16:20:35 SQL> BEGIN16:20:42 2 DBMS_WORKLOAD_CAPTURE.EXPORT_AWR (capture_id => 3);16:20:42 3 END;16:20:42 4 /

Page 46: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

46/74

PL/SQL procedure successfully completed.

Elapsed: 00:14:32.87

The export_awr generated this file on the capture directory for capture_id 3:

09/28/2008 04:35 PM 1,588,432,896 WCR_CA.DMP

Generating a Workload Capture Report Using APIs

Before applying the captured workload it is convenient to check it. To do that we use the workload capture reportthat contains captured workload statistics, information about the top session activities that were captured, and anyworkload filters used during the capture process.

To generate a report on the latest workload capture, use theDBMS_WORKLOAD_CAPTURE.GET_CAPTURE_INFO procedure and theDBMS_WORKLOAD_CAPTURE.REPORT function:

DECLAREcap_id NUMBER;cap_rpt CLOB;

BEGINcap_id := DBMS_WORKLOAD_CAPTURE.GET_CAPTURE_INFO(dir => 'LOADCAPT');cap_rpt := DBMS_WORKLOAD_CAPTURE.REPORT(capture_id => 3,

format => DBMS_WORKLOAD_CAPTURE.TYPE_TEXT);END;/

Page 47: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

47/74

Workload Preprocessing

Once the workload has been captured, the information in the capture files need to be preprocessed.

Preprocessing creates all necessary metadata needed for replaying the workload.

This must be done once for every captured workload before they can be replayed.

After the captured workload is preprocessed, it can be replayed repeatedly on a replay system running the sameversion of Oracle Database.

On the 11g database create a directory pointing to the directory where the capture load files are located

create or replace directory LOADCAPT as 'E:\RAT_LOAD_CAPTURE';grant read , write on directory LOADCAPT to public;

SQL> EXEC DBMS_WORKLOAD_REPLAY.PROCESS_CAPTURE(capture_dir=>'LOADCAPT');

PL/SQL procedure successfully completed.

Workload Replay

Workload reply has the following stages:

Setting Up the Test System: You need to prepare the database to replay, usually you will make a backup of thedatabase where the originated workload was captured, and upgrade it or migrate it to match the new scenario.

On this case I’m using an export from the 10g database and import on the 11g database:

Export file: EXPDAT.DMP > avargas.dmp

Page 48: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

48/74

(1)E(ntire database), (2)U(sers), or (3)T(ables): (2)U > 2Export grants (yes/no): yes >Export table data (yes/no): yes >Compress extents (yes/no): yes >Export done in IW8ISO8859P8 character set and AL16UTF16 NCHAR character setAbout to export specified users ...User to be exported: (RETURN to quit) > avargasUser to be exported: (RETURN to quit) >. exporting pre-schema procedural objects and actions. exporting foreign function library names for user AVARGAS. exporting PUBLIC type synonyms. exporting private type synonyms. exporting object type definitions for user AVARGASAbout to export AVARGAS's objects .... exporting database links. exporting sequence numbers. exporting cluster definitions. about to export AVARGAS's tables via Conventional Path .... . exporting table TEST1 562461 rows exported. . exporting table TEST2 0 rows exported. exporting synonyms. exporting views. exporting stored procedures. exporting operators. exporting referential integrity constraints. exporting triggers. exporting indextypes. exporting bitmap, functional and extensible indexes. exporting posttables actions. exporting materialized views. exporting snapshot logs. exporting job queues. exporting refresh groups and children. exporting dimensions

Page 49: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

49/74

. exporting post-schema procedural objects and actions

. exporting statisticsExport terminated successfully without warnings.

On 11g:

SQL> CREATE TABLESPACE AVTEST ;Tablespace created.

SQL> CREATE USER AVARGAS IDENTIFIED BY ORACLE DEFAULT TABLESPACE AVTEST TEMPORARY TABLESPACETEMP;User created.

SQL> GRANT DBA, ALL PRIVILEGES TO AVARGAS;Grant succeeded.

E:\RAT_LOAD_CAPTURE>imp avargasImport: Release 11.1.0.6.0 - Production on Thu Oct 2 12:34:27 2008Copyright (c) 1982, 2007, Oracle. All rights reserved.Password:Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsImport file: EXPDAT.DMP > avargas.dmpEnter insert buffer size (minimum is 8192) 30720>Export file created by EXPORT:V10.02.01 via conventional pathimport done in IW8MSWIN1255 character set and AL16UTF16 NCHAR character setimport server uses IW8ISO8859P8 character set (possible charset conversion)export client uses IW8ISO8859P8 character set (possible charset conversion)List contents of import file only (yes/no): no >Ignore create error due to object existence (yes/no): no >Import grants (yes/no): yes >Import table data (yes/no): yes >Import entire export file (yes/no): no > yes. importing AVARGAS's objects into AVARGAS

Page 50: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

50/74

. . importing table "TEST1" 562461 rows imported

. . importing table "TEST2" 0 rows imported

Import terminated successfully without warnings.

Steps for Replaying a Database Workload

Replay is implemented invoking the wrc utility from the 11g $ORACLE_HOME/bin directory.

First we run it using the calibrate option, that provide information on the captured load that we can use to executethe replay:

E:\RAT_LOAD_CAPTURE>d:D:\ORACLE\11g\db11g\BIN>cd D:\ORACLE\11g\db11g\binD:\ORACLE\11g\db11g\BIN>wrc mode=calibrate replaydir=E:\RAT_LOAD_CAPTURE

Workload Replay Client: Release 11.1.0.6.0 - Production on Thu Oct 2 12:45:27 2008Copyright (c) 1982, 2007, Oracle. All rights reserved.

Report for Workload in: E:\RAT_LOAD_CAPTURE-----------------------Recommendation:Consider using at least 1 clients divided among 1 CPU(s).Workload Characteristics:- max concurrency: 1 sessions- total number of sessions: 1

Assumptions:- 1 client process per 50 concurrent sessions- 4 client process per CPU- think time scale = 100- connect time scale = 100

Page 51: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

51/74

- synchronization = TRUE

Prepare the Replay Database

Before actually replaying the load we need to prepare the replay database

BEGIN DBMS_WORKLOAD_REPLAY.initialize_replay (replay_name => ‘AVTEST_REPLAY', replay_dir => 'LOADCAPT');DBMS_WORKLOAD_REPLAY.prepare_replay (synchronization => TRUE);

END; /

SQL> BEGIN2 DBMS_WORKLOAD_REPLAY.initialize_replay (3 replay_name => 'AVTEST_REPLAY',4 replay_dir => 'LOADCAPT');5 DBMS_WORKLOAD_REPLAY.prepare_replay (6 synchronization => TRUE);7 END;8 /

PL/SQL procedure successfully completed.

Execute the Replay Database

Now we can execute the wrc utility to run the load:

D:\ORACLE\11g\db11g\BIN>wrc avargas/ORACLE@REALAPT mode=replay replaydir=E:\RAT_LOAD_CAPTURE

Page 52: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

52/74

Workload Replay Client: Release 11.1.0.6.0 - Production on Thu Oct 2 13:12:10 2008Copyright (c) 1982, 2007, Oracle. All rights reserved.

Wait for the replay to start (13:12:10)

Left this window open and open a new window for the next step

From within sqlplus start the replay

To actually start the replay we need to execute DBMS_WORKLOAD_REPLAY.start_replay from within sqlplus

BEGINDBMS_WORKLOAD_REPLAY.start_replay;

END;/

E:\RAT_LOAD_CAPTURE>sqlplus / as sysdba

SQL> BEGIN2 DBMS_WORKLOAD_REPLAY.start_replay;3 END;4 /

PL/SQL procedure successfully completed.

The wrc utility will show that replay started

D:\ORACLE\11g\db11g\BIN>wrc avargas/ORACLE@REALAPT mode=replay replaydir=E:\RAT_LOAD_CAPTUREWorkload Replay Client: Release 11.1.0.6.0 - Production on Thu Oct 2 13:12:10 2008Copyright (c) 1982, 2007, Oracle. All rights reserved.Wait for the replay to start (13:12:10)Replay started (13:15:46)Replay finished (13:23:02)

Page 53: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

53/74

Once the replay finish we can analyze its performance

SQL> COLUMN name FORMAT A20SQL> SELECT id, name FROM dba_workload_replays;

ID NAME---------- --------------------

1 AVTEST_REPLAY

DECLARE l_report CLOB; BEGIN l_report := DBMS_WORKLOAD_REPLAY.report(replay_id => 1, format =>DBMS_WORKLOAD_REPLAY.TYPE_HTML); END;/

SQL> DECLARE2 l_report CLOB;3 BEGIN4 l_report:= DBMS_WORKLOAD_REPLAY.report(replay_id => 1, format =>

DBMS_WORKLOAD_REPLAY.TYPE_HTML);5 END;6 /

PL/SQL procedure successfully completed.It is possible to check the awr reports the replay span to further check replay performance

SQL> col name for a20SQL> l

1* select id,name,AWR_BEGIN_SNAP,AWR_END_SNAP from DBA_WORKLOAD_REPLAYSSQL> /

Page 54: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

54/74

ID NAME AWR_BEGIN_SNAP AWR_END_SNAP---------- -------------------- -------------- ------------

1 AVTEST_REPLAY 167 168

SQL> @?/rdbms/admin/awrrpt

Current Instance~~~~~~~~~~~~~~~~

DB Id DB Name Inst Num Instance----------- ------------ -------- ------------3981543668 REALAPT 1 realapt

Specify the Report Type~~~~~~~~~~~~~~~~~~~~~~~Would you like an HTML report, or a plain text report?Enter 'html' for an HTML report, or 'text' for plain textDefaults to 'html'Enter value for report_type: text

Type Specified: text......

End of ReportReport written to awrrpt_1_167_168.txt

Page 55: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

55/74

SQL Performance Analyzer

SQL Performance Analyzer Workflow Steps

Capture the SQL workload: Capture the set of SQL statements in a SQL Tuning Set (STS)

Measure the performance of the workload before the change: SQL Performance Analyzer executes the SQLstatements captured in the SQL Tuning Set and generates execution plans and execution statistics for eachstatement.

Make a change: Make the change whose effect on SQL performance you intend to measure. SQL PerformanceAnalyzer can analyze the effect of many types of system changes. For example, you can test a database upgrade,new index creation, initialization parameter changes, optimizer statistics refresh, and so on.

Measure the performance of the workload after the change: After you have made the planned change, SQLPerformance Analyzer re-executes the SQL statements and produces execution plans and execution statistics foreach SQL statement a second time. This execution result represents a new set of performance data that SQLPerformance Analyzer uses for subsequent comparison.

Compare performance: Compares the performance of SQL statements before and after the change and producea report identifying any changes in execution plans or performance of the SQL statements.

Capture the SQL workload using API’s

To capture the SQL workload we use the DBMS_SQLPA package

Page 56: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

56/74

Main Functions of the DBMS_SQLPA Package

Function PurposeCREATE_ANALYSIS_TASK Create a SQL Performance Analyzer task to process and

analyze a SQL Tuning SetSET_ANALYSIS_TASK_PARAMETER Set a SQL analysis task parameter valueEXECUTE_ANALYSIS_TASK Run a previously created taskDROP_ANALYSIS_TASK Drop a task, deleting all performance dataREPORT_ANALYSIS_TASK Generate a report of analysis task results

Create An Empty Sql Tuning Set To Be Populated With Some Load

BEGINDBMS_SQLTUNE.CREATE_SQLSET(

sqlset_name => 'RATSQLATEST', description => 'RAT SQL Analyzer Test');

END;/

SQL> BEGIN2 DBMS_SQLTUNE.CREATE_SQLSET(3 sqlset_name => 'RATSQLATEST',4 description => 'RAT SQL Analyzer Test');5 END;6 /

PL/SQL procedure successfully completed.

Load SQL Statements on the STS

First we can create a simulated load, i.e.:

Page 57: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

57/74

E:\RAT_SQL_ANALYZE>sqlplus avargas/oracle

SQL> @runloadTable truncated.678266 rows created.236 rows created.678266 rows deleted.Commit complete.

That keeps running in a cycle for a while, and then we check the snapshot id’s and create a new AWRsnapshot

EXEC dbms_workload_repository.create_snapshot;

SQL> EXEC dbms_workload_repository.create_snapshot;

PL/SQL procedure successfully completed.

Now we get the last snapshot_ids and use them to gather the sql statement

SnapInstance DB Name Snap Id Snap Started Level------------ ------------ --------- ------------------ -----ORCL ORCL 17388 02 Oct 2008 15:00 1

17389 02 Oct 2008 15:12 1

The LOAD_SQLSET procedure populates the STS with selected SQL statements. An STS can be loaded fromstatements coming from the workload repository, another STS, or the cursor cache.

For both the workload repository and STS, predefined table functions can be used to select columns from thesource to populate a new STS.

Page 58: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

58/74

In the following example, procedure calls are used to load 'RATSQLATEST' from AWR reports.

The data has been filtered to select only the top 30 SQL statements.

First a ref cursor is opened to select from the specified AWR reports. Next the statements and their statistics areloaded into the STS.

FUNCTION SELECT_WORKLOAD_REPOSITORY RETURNS SQLSET

Argument Name Type In/Out Default?------------------------------ ----------------------- ------ --------BEGIN_SNAP NUMBER IN END_SNAP NUMBER IN BASIC_FILTER VARCHAR2 IN DEFAULTOBJECT_FILTER VARCHAR2 IN DEFAULTRANKING_MEASURE1 VARCHAR2 IN DEFAULTRANKING_MEASURE2 VARCHAR2 IN DEFAULTRANKING_MEASURE3 VARCHAR2 IN DEFAULTRESULT_PERCENTAGE NUMBER IN DEFAULTRESULT_LIMIT NUMBER IN DEFAULTATTRIBUTE_LIST VARCHAR2 IN DEFAULT

DECLAREl_cursor dbms_sqltune.sqlset_cursor;

BEGINOPEN l_cursor FORSELECT VALUE(p)FROM TABLE (dbms_sqltune.select_workload_repository ( 17388, -- begin_snap 17389, -- end_snapNULL, -- basic_filterNULL, -- object_filterNULL, -- ranking_measure1

Page 59: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

59/74

NULL, -- ranking_measure2NULL, -- ranking_measure3NULL, -- result_percentage30)) p; -- result_limit

dbms_sqltune.load_sqlset (sqlset_name =>'RATSQLATEST', populate_cursor => l_cursor);

END;/

SQL> DECLARE2 l_cursor dbms_sqltune.sqlset_cursor;3 BEGIN4 OPEN l_cursor FOR5 SELECT VALUE(p)6 FROM TABLE (dbms_sqltune.select_workload_repository (7 17388, -- begin_snap8 17389, -- end_snap9 NULL, -- basic_filter10 NULL, -- object_filter11 NULL, -- ranking_measure112 NULL, -- ranking_measure213 NULL, -- ranking_measure314 NULL, -- result_percentage15 30)) p; -- result_limit1617 dbms_sqltune.load_sqlset (sqlset_name =>18 'RATSQLATEST', populate_cursor => l_cursor);19 END;20 /

PL/SQL procedure successfully completed.

Page 60: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

60/74

Displaying the Contents of a SQL Tuning Set

The SELECT_SQLSET table function reads the contents of the STS. After an STS has been created andpopulated, you can browse the SQL in the STS using different filtering criteria.

The SELECT_SQLSET procedure is provided for this purpose.

In the following example, the SQL statements in the STS are displayed for statements with a disk-reads to buffer-gets ratio greater than or equal to 75%.

SELECT * FROM TABLE(DBMS_SQLTUNE.SELECT_SQLSET('RATSQLATEST'));

SQL> SELECT * FROM TABLE(DBMS_SQLTUNE.SELECT_SQLSET('RATSQLATEST'));

SQL_ID FORCE_MATCHING_SIGNATURE SQL_TEXT------------- ------------------------ ----------------------------OBJECT_LIST-----------------------------------------------------------------------------------------------------------------BIND_DATA-----------------------------------------------------------------------------------------------------------------PARSING_SCHEMA_NAME MODULE ACTION ELAPSED_TIME CPU_TIME BUFFER_GETS DISK_READS DIRECT_WRITES ROWS_PROCESSED FETCHES------------------------------ ------------------------------------------------ -------------------------------- EXECUTIONS END_OF_FETCH_COUNT OPTIMIZER_COST---------- ------------------ --------------OPTIMIZER_ENV-----------------------------------------------------------------------------------------------------------------

Page 61: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

61/74

PRIORITY COMMAND_TYPE FIRST_LOAD_TIME STAT_PERIOD ACTIVE_STAT_PERIOD OTHER PLAN_HASH_VALUE---------- ------------ ------------------- ----------- ------------------ --------------------------------------SQL_PLAN(STATEMENT_ID, PLAN_ID, TIMESTAMP, REMARKS, OPERATION, OPTIONS, OBJECT_NODE,OBJECT_OWNER, OBJECT_NAME, OBJECT_ALIAS, OBJECT_INSTANCE, OBJECT_TYPE, OPTIMIZER, SEARCH_COLUMNS, ID, PARENT_ID, DE-----------------------------------------------------------------------------------------------------------------BIND_LIST()-----------------------------------------------------------------------------------------------------------------fsda22kwya1gu 8.1404E+18 delete from test2

AVARGAS SQL*Plus 61499 61499 5434 0

0 4720 020 20 2

E289FB89A3E49800C4001000AEF9C3E2CFFA332056414555519521105555551545545558591555449665851D5511 058555155515152552455580185AA3E49800050402000002000000100000000100002000000210D007000000D00700002003000101000038F8000200000090010000E80300A3E4980004656464020264320

7 1562589875

8ypwcums111db 3.1389E+18 select distinct(case when cd.dbid = wr.dbid and

cd.nam

Page 62: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

62/74

SYS sqlplus.exe 859382 15806 37 12

0 2 21 1 335

E289FB89A3E49800C4001000AEF9C3E2CFFA332056414555519521105555551545545558591555449665851D5511 058555155515152552455580185AA3E49800050402000002000000100000000100002000000210D007000000D00700002003000101000038F8000200000090010000E80300A3E4980004656464020264320

3 3511428958

3xpsk5cub3nvc 1.8204E+19 delete from test1

AVARGAS SQL*Plus 276172192 140496807 15409663 16

0 13565320 020 20 2669

E289FB89A3E49800C4001000AEF9C3E2CFFA332056414555519521105555551545545558591555449665851D5511 058555155515152552455580185AA3E49800050402000002000000100000000100002000000210D007000000D0070000200300010100

Additional details of the SQL Tuning Sets that have been created and loaded can also be displayed with DBAviews, such as DBA_SQLSET, DBA_SQLSET_STATEMENTS, and DBA_SQLSET_BINDS.

Page 63: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

63/74

Transporting a SQL Tuning Set

SQL Tuning Sets can be transported to another system by first exporting the Sql Tuning Set (STS) from onesystem to a staging table, then importing the STS from the staging table into another system.

To transport a SQL Tuning Set:

Use the CREATE_STGTAB_SQLSET procedure to create a staging table where the SQL Tuning Sets will beexported.

BEGINDBMS_SQLTUNE.CREATE_STGTAB_SQLSET( table_name => 'RAT_SQLANL_TAB' );

END;/

SQL> BEGIN2 DBMS_SQLTUNE.CREATE_STGTAB_SQLSET( table_name => 'RAT_SQLANL_TAB' );3 END;4 /

PL/SQL procedure successfully completed.

Use the PACK_STGTAB_SQLSET procedure to export SQL Tuning Sets into the staging table.

BEGINDBMS_SQLTUNE.PACK_STGTAB_SQLSET(sqlset_name => 'RATSQLATEST',staging_table_name =>'RAT_SQLANL_TAB');

END;/

Page 64: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

64/74

SQL> BEGIN2 DBMS_SQLTUNE.PACK_STGTAB_SQLSET(3 sqlset_name => 'RATSQLATEST',4 staging_table_name =>'RAT_SQLANL_TAB');5 END;6 /

PL/SQL procedure successfully completed.

Transport The Load Table To The Test System

E:\RAT_SQL_ANALYZE>exp 'sys as sysdba'

Export: Release 10.2.0.3.0 - Production on Thu Oct 2 15:58:02 2008

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Password:

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsEnter array fetch buffer size: 4096 >

Export file: EXPDAT.DMP > ratsqlanl.dmp

(1)E(ntire database), (2)U(sers), or (3)T(ables): (2)U > 3

Export table data (yes/no): yes >

Compress extents (yes/no): yes >

Export done in IW8ISO8859P8 character set and AL16UTF16 NCHAR character set

Page 65: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

65/74

About to export specified tables via Conventional Path ...Table(T) or Partition(T:P) to be exported: (RETURN to quit) > RAT_SQLANL_TAB

. . exporting table RAT_SQLANL_TAB 30 rows exported

. . exporting table RAT_SQLANL_TAB_CBINDS 0 rows exported

. . exporting table RAT_SQLANL_TAB_CPLANS 0 rows exportedTable(T) or Partition(T:P) to be exported: (RETURN to quit) >

Export terminated successfully without warnings.

FTP the table to the test system

C:\Documents and Settings >dirVolume in drive C has no label.Volume Serial Number is C49B-DFB9

Directory of C:\Documents and Settings

07/20/2008 11:29 AM <DIR> .07/20/2008 11:29 AM <DIR> ..10/02/2008 03:59 PM 79,872 ratsqlanl.dmp

3 File(s) 84,385 bytes6 Dir(s) 6,144,704,512 bytes free

C:\Documents and Settings >ftp linuxConnected to linux220 (vsFTPd 1.2.1)User (linux:(none)): oracle331 Please specify the password.Password:230 Login successful.ftp> bin

Page 66: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

66/74

200 Switching to Binary mode.ftp> put ratsqlanl.dmp200 PORT command successful. Consider using PASV.150 Ok to send data.226 File receive OK.ftp: 79872 bytes sent in 0.00Seconds 79872000.00Kbytes/sec.

On the system where the SQL Tuning Sets will be imported, use the UNPACK_STGTAB_SQLSET procedure toimport SQL Tuning Sets from the staging table.

linux /home/oracle> ls -ltr *dmp-rw-r--r-- 1 oracle oinstall 79872 2008-10-02 16:05 ratsqlanl.dmp

linux /home/oracle> imp

Import: Release 10.2.0.3.0 - Production on Thu Oct 2 16:10:50 2008

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Username: sys as sysdbaPassword:

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP and Data Mining options

Import file: expdat.dmp > ratsqlanl.dmp.........

" scale NUMBER, /* bind sca""le */"" max_length NUMBER, /* maximum bind leng""th */"

Page 67: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

67/74

" last_captured DATE, /* DATE when this bind variable was captur""ed */"" value_string VARCHAR2(4000), /* bind value (text representatio""n) */"" value_anydata ANYDATA) /* bind value (anydata representatio""n) */"

IMP-00015: following statement failed because the object already exists:"CREATE TYPE "SQL_BIND_SET" TIMESTAMP '2007-07-16:18:42:06' OID '00000000000""000000000000000020214' "" AS T""ABLE OF sql_bind"

. . importing table "RAT_SQLANL_TAB" 30 rows imported

. . importing table "RAT_SQLANL_TAB_CBINDS" 0 rows imported

. . importing table "RAT_SQLANL_TAB_CPLANS" 0 rows imported

Import terminated successfully with warnings.

BEGINDBMS_SQLTUNE.UNPACK_STGTAB_SQLSET(

sqlset_name => '%',replace => TRUE,staging_table_name => 'RAT_SQLANL_TAB');

END;/

Page 68: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

68/74

Unpack the STS Into the Test System

SQL*Plus: Release 10.2.0.3.0 - Production on Thu Oct 2 16:12:24 2008

Copyright (c) 1982, 2006, Oracle. All Rights Reserved.

Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP and Data Mining options

SQL > BEGINDBMS_SQLTUNE.UNPACK_STGTAB_SQLSET(

sqlset_name => '%',replace => TRUE,staging_table_name => 'RAT_SQLANL_TAB');

END;/

PL/SQL procedure successfully completed.Prepare the test database to run the load

Prepare The Test System

SQL > CREATE TABLESPACE AVTEST ;

Tablespace created.

SQL > CREATE USER AVARGAS IDENTIFIED BY ORACLE DEFAULT TABLESPACE AVTEST TEMPORARYTABLESPACE TEMP;

Page 69: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

69/74

User created.

SQL > GRANT DBA, ALL PRIVILEGES TO AVARGAS;

Grant succeeded.

SQL > connect avargas/oracleConnected.

SQL > create table test1 as select * from dba_source where 1=2;

Table created.

SQL > create table test2 as select * from dba_users where 1=2;

Table created.

Creating a SQL Performance Analyzer Task

The next stage is to run the load on the target database.

For this purpose we need to create an SQL Performance Analyzer task by using theDBMS_SQLPA.CREATE_ANALYSIS_TASK function.

The CREATE_ANALYSIS_TASK function use the following parameters:

task_name specify an optional name for the SQL Performance Analyzer task.sqlset_name the name of the SQL Tuning Set.sqlset_owner the owner of the SQL Tuning Set. The default is the current schema owner.basic_filter the SQL predicate used to filter the SQL from the SQL Tuning Set.order_by specify an order-by clause on the selected SQL.

Page 70: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

70/74

top_sql consider only the top number of SQL statements after filtering and ranking.

VARIABLE sts_task VARCHAR2(100);

EXEC :sts_task := DBMS_SQLPA.CREATE_ANALYSIS_TASK( -sqlset_name => 'RATSQLATEST', -description => 'process test workload');

SQL> VARIABLE sts_task VARCHAR2(100);SQL> EXEC :sts_task := DBMS_SQLPA.CREATE_ANALYSIS_TASK( -> sqlset_name => 'RATSQLATEST', -> task_name => 'RAT_SQLANL', -> description => 'process test workload');

PL/SQL procedure successfully completed.

Executing the SQL Workload Before a Change

Once the analysis task was created we can execute it

These are guidelines to setup the DBMS_SQLPA.EXECUTE_ANALYSIS_TASK execution:

• Set the task_name parameter to the name of the SQL Performance Analyzer task that you want to execute.• Set the execution_type parameter in either of the following ways:

§ Set to EXPLAIN PLAN to generate execution plans for all SQL statements in the SQL Tuning Set withoutexecuting them.

§ Set to TEST EXECUTE (recommended) to execute all statements in the SQL Tuning Set and generatetheir execution plans and statistics. When TEST EXECUTE is specified, the procedure generatesexecution plans and execution statistics. The execution statistics enable SQL Performance Analyzer to

Page 71: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

71/74

identify SQL statements that have improved or regressed. Collecting execution statistics in addition togenerating execution plans provides greater accuracy in the performance analysis, but takes longer.

• Specify a name to identify the execution using the execution_name parameter. If not specified, then SQLPerformance Analyzer automatically generates a name for the task execution.

• Specify execution parameters using the execution_params parameters. The execution_params parameters arespecified as (name, value) pairs for the specified execution. For example, you can set the following executionparameters:

• The time_limit parameter specifies the global time limit to process all SQL statements in a SQL Tuning Setbefore timing out.

• The local_time_limit parameter specifies the time limit to process each SQL statement in a SQL Tuning Setbefore timing out.

EXEC DBMS_SQLPA.EXECUTE_ANALYSIS_TASK(task_name => 'RAT_SQLANL', -execution_type => 'TEST EXECUTE', - execution_name => 'my_exec_BEFORE_change');

SQL> EXEC DBMS_SQLPA.EXECUTE_ANALYSIS_TASK(task_name => 'RAT_SQLANL', -> execution_type => 'TEST EXECUTE', -> execution_name => 'my_exec_BEFORE_change');

PL/SQL procedure successfully completed.

New analysis can be generated and comparison reports can be generated usingDBMS_SQLPA.REPORT_ANALYSIS_TASK

Page 72: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

72/74

Generate an Report with Analysis Of Task Results

SELECT DBMS_SQLPA.REPORT_ANALYSIS_TASK(:sts_task, 'TEXT', 'TYPICAL', 'SUMMARY')FROM DUAL;

SQL> set pages 50000 lines 200 long 50000SQL> SELECT DBMS_SQLPA.REPORT_ANALYSIS_TASK('RAT_SQLANL', 'TEXT', 'TYPICAL', 'SUMMARY') fromdual;

DBMS_SQLPA.REPORT_ANALYSIS_TASK('RAT_SQLANL','TEXT','TYPICAL','SUMMARY')--------------------------------------------------------------------------------GENERAL INFORMATION SECTION-------------------------------------------------------------------------------Tuning Task Name : RAT_SQLANLTuning Task Owner : SYSWorkload Type : SQL Tuning SetExecution Count : 1Current Execution : my_exec_BEFORE_changeExecution Type : TEST EXECUTEScope : COMPREHENSIVECompletion Status : COMPLETEDStarted at : 10/02/2008 17:39:36Completed at : 10/02/2008 17:39:52SQL Tuning Set (STS) Name : RATSQLATESTSQL Tuning Set Owner : SYSNumber of Statements in the STS : 29Number of SQLs Analyzed : 29Number of SQLs in the Report : 29Number of SQLs with Findings : 2Number of SQLs with Errors : 1

-------------------------------------------------------------------------------SUMMARY SECTION

Page 73: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

73/74

-------------------------------------------------------------------------------SQL Statements Ordered by Elapsed Time

-------------------------------------------------------------------------------Parse Elapsed CPU Buffer Optimizer

object ID SQL ID Time (s) Time (s) Time (s) Gets Cost---------- ------------- -------- -------- -------- -------- ---------

27 frvhw30vv4z2t .073 6.206 1.781 17609 13249 3xpsk5cub3nvc 0 5.149 .578 20867 3297

29 g337099aatnuj .029 1.29 .015 492 1033 0j80bq6arfp1h 0 .261 .015 208 59

23 bunssq950snhf .05 .182 .125 170 010 47a50dvdgnxc2 .059 .122 0 91 115 84qubbrsr0kfn .003 .107 0 251 116 88cwftrsh6rjb .02 .067 .015 119 125 d8mayxqw0wnpv .184 .043 0 149 297 31a13pnjps7j3 .029 .015 0 36 28

12 4t21k5qn4rwpb .125 .013 0 2 917 8ypwcums111db .022 .011 0 7 165 1gu8t96d0bdmu .033 .01 0 2 2

18 9410b66vr6543 .047 .01 0 2 76 2q93zsrvbdw48 0 .009 0 3 4

28 fsda22kwya1gu 0 .008 0 3 211 4g4k54qrsawn6 .017 .007 0 2 413 6aq34nj2zb2n7 0 .005 0 2 419 9g485acn2n30m .021 .002 0 1 220 aq8yqxyyb40nn 0 .001 0 1 12 04xtrk7uyhknh 0 0 0 3 4

14 6hfvjdrkp32x3 .009 0 0 0 021 bhvyz9bgyrhb2 0 0 0 2 322 bsa0wjtftg3uw 0 0 0 3 224 c6awqs517jpj0 .022 0 0 2 330 gdn3ysuyssf82 0 0 0 1 1

-------------------------------------------------------------------------------

Page 74: REAL APPLICATION TESTING ON 10G – STEP BY STEP fileREAL APPLICATION TESTING ON 10G – STEP BY STEP 1/74 Alejandro Vargas Principal Support Consultant Oracle Advanced Customer Services

REAL APPLICATION TESTING ON 10G – STEP BY STEP

74/74

Statements with Errors-------------------------------------------------------------------------------object ID SQL ID Error---------- ------------- ------------------------------------------------------

26 d9zm7p74x91sn ORA-01410: invalid ROWID

-------------------------------------------------------------------------------

End of Report