Documente Academic
Documente Profesional
Documente Cultură
This step can take a while. It runs the queries from the STS and stores their ex
ecution statistics. In order to do that, you must:
a.)Create a SQLPA analysis task that reference the STS:
var v_out char(50)
begin
:v_out:=dbms_sqlpa.create_analysis_task(
sqlset_name => 'gark_sts',
task_name => 'gark_spa_task');
end;
/
print v_out
V_OUT
------------gark_spa_task
b.)Check the task has been created:
col TASK_NAME format a14
col ADVISOR_NAME format a24
select TASK_NAME,
ADVISOR_NAME,
created
from DBA_ADVISOR_TASKS
where task_name='gark_spa_task';
TASK_NAME
ADVISOR_NAME
CREATED
-------------- ------------------------ --------gark_spa_task SQL Performance Analyzer 15-AUG-07
Run the SQLPA Analysis Task:
begin
DBMS_SQLPA.EXECUTE_ANALYSIS_TASK(
task_name
=> 'gark_spa_task',
execution_type => 'TEST EXECUTE',
execution_name => 'gark_spa_task_before');
end;
/
c.)Monitor the task and its status until it is completed:
col TASK_NAME format a20
select execution_name,
status,
execution_end
from DBA_ADVISOR_EXECUTIONS
where task_name='gark_spa_task'
order by execution_end;
EXECUTION_NAME
STATUS
EXECUTION
------------------------------ ----------- --------gark_spa_task_before
COMPLETED 15-AUG-07
-- Perform the changes.
I
m not very proud of this change, but lets create an index on the GARK table.
Index created.
-- Run the SQLPA analysis task after the changes
The script is similar from the previous run. You just have to change the name to
differentiate execution statistics before and after the changes:
Run the SQLPA Analysis Task:
begin
DBMS_SQLPA.EXECUTE_ANALYSIS_TASK(
task_name
=> 'gark_spa_task',
execution_type => 'TEST EXECUTE',
execution_name => 'gark_spa_task_after');
end;
/
Monitor the task and its status until it is completed:
col TASK_NAME format a20
select execution_name,
status,
execution_end
from DBA_ADVISOR_EXECUTIONS
where task_name='gark_spa_task'
order by execution_end;
EXECUTION_NAME
-----------------------------gark_spa_task_before
gark_spa_task_after
STATUS
----------COMPLETED
COMPLETED
EXECUTION
--------15-AUG-07
15-AUG-07
where task_name='gark_spa_task';
no rows selected
Note that you can also:
cancel a running analysis task with the cancel_analysis_task procedure
interrupt a running analysis task with the interrupt_analysis_task procedure
resume an interrupted analysis task with the resume_analysis_task procedure
To clean the table and index we ve used for this demo:
drop table gark cascade constraints purge;
-- Conclusion
This demonstration is very basic, but running the task on a test database with h
undreds or thousands of queries won t really be more complex
it simply might take more time.
SQL Performance Analyzer is very different from Database Replay. I
our own conclusions about the pros and cons: