Oracle SQL REPLAY & Sql Performance Analyzer(SPA) Part 1
Posted by virags on August 12, 2007
You can use Sql Performance Analyzer (SPA) to analyze the SQL performance impact of any type of system changes.
- Implementation of tuning recommendations ( like parameter changes )
- Schema changes (eg Application Patch )
- Statistics gathering
- Database upgrades
- OS/hardware changes
SQL Performance Analyzer allows for the comparison of SQL performance statistics before and after changes and provide comparison report.
Steps for SQL REPLAY
- Collect Sqls
- Create the SQL Replay Task with SQL Tuning Set (STS)
- Collect SQL Performance Before Changes
- Make Database Change ( eg collect stats etc)
- Collect SQL Performance After Changes
- Comparing SQL Performance Before and After Change
- Display the Results of a SQL Replay Task
Steps in details
1. Collect SQL
To create an SQL Tuning Set (STS)
|
exec dbms_sqltune.create_sqlset (‘MYSQLSET’); PL/SQL procedure successfully completed. |
Collect sqls in the SQL Tuning Set(STS) with all queries from the cursor cache.
You can call the procedure multiple times to add new SQL statements or replace
attributes of existing statements.
|
DECLARE cur dbms_sqltune.sqlset_cursor; BEGIN OPEN cur FOR dbms_sqltune.load_sqlset( /
|
Collect sql mentioned in AWR as well , You populate the tuning set with ‘ACCUMULATE’ as yourupdate_option because it is assumed the cursors currently in the cache had aged out since the snapshot was taken.
|
DECLARE OPEN cur FOR DBMS_SQLTUNE.LOAD_SQLSET(sqlset_name => ‘MYSQLSET’, END; Note 1 is start snap id and 100 is END snap ID |
- Create the SQL Replay Task with SQL Tuning Set (STS)
Create the SQL Replay Task with SQL Tuning Set(STS) named MYSQLSET
|
var l_task_id char(30) / |
Collect SQL Performance data Before Changes
| begin DBMS_SQLPA.EXECUTE_ANALYSIS_TASK( task_name => ‘MY_REPLAY_TASK’, execution_type => ‘TEST EXECUTE’, execution_name => ‘MY_REPLAY_EXECUTE_BEFORE’); end; / |
- Make Database Change ( eg collect stats etc)
Make application , database changes
|
alter system set “_b_tree_bitmap_plans” = false; alter system set optimizer_index_cost_adj=15 |
- Collect SQL Performance After Changes
| begin DBMS_SQLPA.EXECUTE_ANALYSIS_TASK( task_name => ‘MY_REPLAY_TASK’, execution_type => ‘TEST EXECUTE’, execution_name => ‘MY_REPLAY_EXECUTE_after’); end; / |
- Comparing SQL Performance Before and After Change
Analyze the Performance (Improvement or regressions)
|
begin
|
- Display the Results of a SQL Replay Task
– Checking the Status of a SQL Tuning TaskSELECT status FROM USER_ADVISOR_TASKS WHERE task_name = 'MY_REPLAY_TASK' – Checking the Progress of the SQL Tuning AdvisorSELECT sofar, totalwork FROM V$ADVISOR_PROGRESS WHERE task_name = 'MY_REPLAY_TASK' –Displaying the Results of a SQL Tuning Taskset serveroutput on size 999999 set long 999999 select DBMS_SQLPA.REPORT_ANALYSIS_TASK(‘MY_REPLAY_TASK’) from dual; –Note above command will take few Min. OR VAR rep CLOB;
|
|
- Sample Output of report Projected Workload Change Impact: REP SQL Statement Count |
In this article Sql Performance Analyzer Part 1,we just covered Sql Performance Analyzer (SPA) basic functionality , In part 2 I will cover more expects and case study of SPA
Some more article on 11g
- Oracle 11g TOP feature for DBA
- 11g Automatic Diagnostic Repository (ADR)
- Sql Performance Analyzer (SPA) Part 1
- Sql Performance Analyzer (SPA) Part 2
SQL Tuning Information Views
· Advisor views,
DBA_ADVISOR_TASKDBA_ADVISOR_EXECUTIONS,DBA_ADVISOR_FINDINGSDBA_ADVISOR_RECOMMENDATIONSDBA_ADVISOR_RATIONALEviews
· SQL tuning views,
DBA_SQLTUNE_STATISTICSDBA_SQLTUNE_BINDS, andDBA_SQLTUNE_PLANSviews
· SQL Tuning Set views,
DBA_SQLSET,DBA_SQLSET_BINDS,DBA_SQLSET_STATEMENTS,DBA_SQLSET_REFERENCESviews.
· Captured execution plans for statements in SQL Tuning Sets
DBA_SQLSET_PLANSUSER_SQLSET_PLANS
· SQL tuning view,
V$SQL,V$SQLAREA,V$SQLSTATS,V$SQL_BINDSviews
· SQL Profile information is displayed in the DBA_SQL_PROFILES view.
The TYPE parameter shows if the SQL profile was created manually by the SQL Tuning Advisor (if TYPE = MANUAL) or automatically by automatic SQL tuning (if TYPE = AUTO).
· Advisor execution progress information is displayed in the V$ADVISOR_PROGRESS view.
References
Tonguç said
Thank you for sharing, my question is can this option capture select and non-database pl/sql load also? If so it can not be redo based like streams technology which is the right way of handling the mentioned needs.
Best regards.