Skip to content

Commit 67a8641

Browse files
Merge pull request #330 from oracle-devrel/ulrike-testingspa
Ulrike testingspa assets
2 parents 393405d + 4d2cc10 commit 67a8641

File tree

14 files changed

+235
-0
lines changed

14 files changed

+235
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Real Application Testing
2+
Real Application Testing comes in two flavors - Database Replay (DB Replay) and SQL Performance Analyzer (SPA). Both can be used independently of each other but are also a good complement.
3+
With SQL Performance Analyzer you can check the SQL performance. It focuses on detailed statement analysis of a defined SQL workload made available via a SQL Tuning Set (STS).
4+
Statements from a SQL workload can be tested and compared and tuned if necessary.
5+
6+
Database Replay can be used to capture a real workload on the production system and replay it on a test system with the exact timing, concurrency, and transaction characteristics of the original workload. This enables you to test the effects of a system change without affecting the production system.
7+
8+
## Useful Links
9+
10+
### Documentation
11+
12+
- [Testing Guide 19c](https://docs.oracle.com/en/database/oracle/oracle-database/19/ratug/index.html#Oracle%C2%AE-Database)
13+
- [PL/SQL Packages and Types Reference](https://docs.oracle.com/en/database/oracle/oracle-database/19/arpls/index.html#Oracle%C2%AE-Database)
14+
15+
16+
### Team Publications
17+
18+
- [Testing with Oracle Database Replay](https://blogs.oracle.com/coretec/post/testing-with-oracle-database-replay)
19+
- [Autonomous Database Replay](https://blogs.oracle.com/coretec/post/adb-database-replay)
20+
- [Real Application Testing Database Replay Demo](https://blogs.oracle.com/coretec/post/rat-demo)
21+
- [Smooth transition to Autonomous Database using SPA](https://blogs.oracle.com/coretec/post/spa-in-autonomous-database)
22+
- [Oracle SQL Tuning Sets (STS) - The foundation for SQL Tuning](https://blogs.oracle.com/coretec/post/oracle-sql-tuning-sets-the-basis-for-sql-tuning)
23+
24+
25+
### LiveLabs Workshops
26+
27+
- [Real Application Testing : SQL Performance Analyzer and Database Replay](https://apexapps.oracle.com/pls/apex/r/dbpm/livelabs/view-workshop?wid=858&clear=RR,180&session=112790027738609)
28+
29+
30+
31+
# License
32+
33+
Copyright (c) 2023 Oracle and/or its affiliates.
34+
35+
Licensed under the Universal Permissive License (UPL), Version 1.0.
36+
37+
See LICENSE for more details.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SQL Performance Analyzer
2+
3+
SQL Performance Analyzer (SPA) as part of Real Application Testing focuses on detailed statement analysis of a defined SQL workload made available via a SQL Tuning Set (STS). The workload runs twice - once BEFORE the change and then AFTER a change. The resulting reports are a detailed comparative analysis (before and after the change) of the individual statements, measured by different metrics such as elapsed time, cpu time, etc. Optionally, you can automate the tuning process using SQL Tuning Advisor or SQL Plan Baselines.
4+
5+
## Useful Links
6+
7+
### Documentation
8+
9+
- [Testing Guide](https://docs.oracle.com/en/database/oracle/oracle-database/19/ratug/sql-performance-analyzer.html#GUID-8CE976A3-FB73-45FF-9B18-A6AB3F158A95)
10+
- [PL/SQL Packages and Types Reference - DBMS_SQLPA](https://docs.oracle.com/en/database/oracle/oracle-database/19/arpls/DBMS_SQLPA.html#GUID-9AAF3672-1CF3-4354-AF41-5BA50BA295F8)
11+
12+
### Team Publication
13+
- [Smooth transition to Autonomous Database using SPA](https://blogs.oracle.com/coretec/post/spa-in-autonomous-database)
14+
- [Oracle SQL Tuning Sets (STS) - The foundation for SQL Tuning](https://blogs.oracle.com/coretec/post/oracle-sql-tuning-sets-the-basis-for-sql-tuning)
15+
16+
### Livelabs/HOL
17+
- [Real Application Testing : SQL Performance Analyzer and Database Replay](https://apexapps.oracle.com/pls/apex/r/dbpm/livelabs/view-workshop?wid=858&clear=RR,180&session=112790027738609)
18+
- [HOL 19c SQL Performance Analyzer](https://mikedietrichde.com/hol-19c-sql-performance-analyzer/)
19+
20+
21+
# License
22+
23+
Copyright (c) 2023 Oracle and/or its affiliates.
24+
25+
Licensed under the Universal Permissive License (UPL), Version 1.0.
26+
27+
See LICENSE for more details.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## scripts-spa
2+
This folder provides SQL scripts for the usage of SQL Performance Analyzer (SPA). They can be used to test changes on the same system or to run tests on a remote server.
3+
4+
Before you start with SQL Performance Analyzer, you need to provide a SQL Tuning Set.
5+
For more information see also:
6+
- [Github scripts for SQL Tuning Sets](https://github.com/oracle-devrel/technology-engineering/tree/main/data-platform/core-converged-db/sql-performance/sql-tuning-sets/scripts-for-sts)
7+
8+
Please note all SQL Performance Analyzer tasks require the privilege ADVISOR.
9+
10+
## SQL Performance Analyzer Scripts
11+
Please follow the steps in the suggested order. In step 2 you can choose between two test scenarios - on the same system or on a remote system. The tuning of regressed statements with SQL Plan Baselines at the end is optional.
12+
13+
1. Create and monitor the tuning task and executions
14+
- Create a SPA task : create-spa-task.sql
15+
- Drop SPA task : drop-spa-task.sql
16+
- Monitor SPA task : monitor-task.sql
17+
- Monitor SPA executions: monitor-executions.sql
18+
19+
Scenario A:
20+
2. Execute trials on the same system
21+
- Execute first trial : trial-execute.sql
22+
- Make changes on the system
23+
- Execute second trial: trial-execute.sql
24+
25+
Scenario B:
26+
2. Import STS on the remote system and use execution statistics for the first trial
27+
- Use the executions statistics for the first trial: trial-use-stats.sql
28+
- Execute the trial (more than once is recommended): trial-execute.sql
29+
30+
31+
3. Generate the comparison results
32+
- Compare performance of two executions: compare-performance.sql
33+
34+
4. Generate reports
35+
- Generate summary report in HTML : report-summary.sql
36+
- Generate detailed report in HTML: report-all-details.sql
37+
38+
39+
Optional:
40+
Tune regressed statements with SQL Plan Baselines
41+
1. Create STS for regressed statements: create-sts-regressed.sql
42+
2. Load original plans : loadplans-for-regressed.sql
43+
44+
# License
45+
Copyright (c) 2023 Oracle and/or its affiliates.
46+
47+
Licensed under the Universal Permissive License (UPL), Version 1.0.
48+
49+
See LICENSE for more details.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
REM Script: compare-performance.sql
2+
REM Compare performance of two executions
3+
4+
-- enter task name (see also monitor-tasks.ql)
5+
-- enter name for execution 1 and execution 2 (monitor-executions.sql lists the execution names)
6+
execute dbms_sqlpa.execute_analysis_task(task_name => '&taskname', execution_type => 'COMPARE PERFORMANCE',execution_params => DBMS_ADVISOR.ARGLIST('execution_name1', '&name1','execution_name2', '&name2'));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
REM Script: create-spa-task.sql
2+
REM Create a SQL Performance Analyzer task
3+
4+
-- enter STS name and owner of the STS
5+
-- print task name
6+
7+
set serveroutput on
8+
declare tname varchar2(100);
9+
begin
10+
tname := dbms_sqlpa.create_analysis_task(sqlset_name => '&STSname', sqlset_owner=>'&STSOwner');
11+
dbms_output.put_line('task name: ' || tname);
12+
end;
13+
/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
REM Script: create-sts-regressed.sql
2+
REM Generate STS for regressed statements
3+
4+
-- create SQL Tuning Set for regressed statements
5+
execute DBMS_SQLTUNE.CREATE_SQLSET(sqlset_name => '&stsname', description=> 'Regressed Statements');
6+
7+
-- use task and execution name from compare-performance.sql or check with monitor-executions.sql
8+
DECLARE
9+
sqlset_cur DBMS_SQLTUNE.SQLSET_CURSOR;
10+
BEGIN
11+
OPEN sqlset_cur FOR
12+
SELECT value(p)
13+
FROM table(
14+
DBMS_SQLTUNE.SELECT_SQLPA_TASK('&taskname', '&STSowner','&execution_name', 'REGRESSED')) p;
15+
DBMS_SQLTUNE.LOAD_SQLSET(sqlset_name => '&STSname', populate_cursor => sqlset_cur);
16+
CLOSE sqlset_cur;
17+
END;
18+
/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
REM Script: drop-spa-task.sql
2+
REM drop SQL Performance Analyzer task
3+
4+
-- enter SPA task name
5+
execute dbms_sqlpa.drop_analysis_task(task_name => '&taskname');
6+
-- check SPA tasks with monitor_task.sql
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
REM Script: loadplans-for-regressed.sql
2+
REM Load original execution plans
3+
4+
-- enter STS name from create-sts-regressed.sql
5+
DECLARE
6+
my_plans PLS_INTEGER;
7+
BEGIN
8+
my_plans := DBMS_SPM.LOAD_PLANS_FROM_SQLSET(sqlset_name => '&STSname');
9+
END;
10+
/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
REM Script: monitor-executions.sql
2+
REM Monitor SQL Performance Analyzer executions
3+
4+
-- list task name and executions for advisor
5+
-- use SQL PERFORMANCE ANALYZER for advisor_name in the case of SPA
6+
col execution_name format a25
7+
col task_name format a25
8+
9+
select task_name, execution_name, status
10+
from dba_advisor_executions where upper(advisor_name)='&Advisorname';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
REM Script: monitor-task.sql
2+
REM Monitor SQL Performance Analyzer task
3+
4+
col owner format a15
5+
col task_name format a30
6+
-- check status and name of SQL Performance Analyzer task
7+
SELECT owner, task_name, status FROM dba_advisor_tasks
8+
WHERE upper(advisor_name)='SQL PERFORMANCE ANALYZER';

0 commit comments

Comments
 (0)