The DBA's time is precious. So, automate and stop wasting it on mundane and tedious tasks. That is what UTL_SPADV
does; it automates the collection of statistics related to Streams performance. UTL_SPADV
is simple to use and once configured, you can forget about it. Then take it to the next level and automated custom reports against the data collected.
UTL_SPADV
has six subprograms. Following are their names along with their definitions:
UTL_SPADV.COLLECT_STATS
UTL_SPADV.COLLECT_STATS( interval IN NUMBER DEFAULT 60, num_runs IN NUMBER DEFAULT 10, comp_stat_table IN VARCHAR2 DEFAULT 'STREAMS$_ADVISOR_COMP_STAT', path_stat_table IN VARCHAR2 DEFAULT 'STREAMS$_ADVISOR_PATH_STAT', top_event_threshold IN NUMBER DEFAULT 15, bottleneck_idle_threshold IN NUMBER DEFAULT 50, bottleneck_flowctrl_threshold IN NUMBER DEFAULT 50);
UTL_SPADV.START_MONITORING
UTL_SPADV.START_MONITORING( job_name IN VARCHAR2 DEFAULT 'STREAMS$_MONITORING_JOB', client_name IN VARCHAR2 DEFAULT NULL, query_user_name IN VARCHAR2 DEFAULT NULL, interval IN NUMBER DEFAULT 60, top_event_threshold IN NUMBER DEFAULT 15, bottleneck_idle_threshold IN NUMBER DEFAULT 50, bottleneck_flowctrl_threshold IN NUMBER DEFAULT 50, retention_time IN NUMBER DEFAULT 24);
UTL_SPADV.IS_MONITORING
UTL_SPADV.IS_MONITORING( job_name IN VARCHAR2 DEFAULT 'STREAMS$_MONITORING_JOB', client_name IN VARCHAR2 DEFAULT NULL) RETURN BOOLEAN;
UTL_SPADV.SHOW_STATS
UTL_SPADV.SHOW_STATS( path_stat_table IN VARCHAR2 DEFAULT 'STREAMS$_ADVISOR_PATH_STAT', path_id IN NUMBER DEFAULT NULL, bgn_run_id IN NUMBER DEFAULT -1, end_run_id IN NUMBER DEFAULT -10, show_path_id IN BOOLEAN DEFAULT TRUE, show_run_id IN BOOLEAN DEFAULT TRUE, show_run_time IN BOOLEAN DEFAULT TRUE, show_optimization IN BOOLEAN DEFAULT TRUE, show_setting IN BOOLEAN DEFAULT FALSE, show_stat IN BOOLEAN DEFAULT TRUE, show_sess IN BOOLEAN DEFAULT FALSE, show_legend IN BOOLEAN DEFAULT TRUE);
UTL_SPADV.ALTER_MONITORING
UTL_SPADV.ALTER_MONITORING( interval IN NUMBER DEFAULT NULL, top_event_threshold IN NUMBER DEFAULT NULL, bottleneck_idle_threshold IN NUMBER DEFAULT NULL, bottleneck_flowctrl_threshold IN NUMBER DEFAULT NULL, retention_time IN NUMBER DEFAULT NULL);
UTL_SPADV.STOP_MONITORING(
purge IN BOOLEAN DEFAULT FALSE);
Using the Streams setup of STRM1
to STRM2
at the beginning of this chapter we will do the following:
UTL_SPADV
using defaults settings. STRM1
to be STREAMed to STRM2
. UTL_SPADV
to more aggressive collection schedule. UTL_SPADV
to stop collection of data.The above should be done as [email protected], except where noted in Step 1.
UTL_SPADV
using defaults settingsFor some unknown reason Oracle decided not to include the package UTL_SPADV
as a default install. So, we have to do some additional work before using it.
GRANT EXECUTE ON sys.dbms_lock TO STRM_ADMIN;
STRM_ADMIN
utlspadv.sql
script. ORACLE_HOME/ rdbms/admin
directory@utlspadv.sql
Use UTL_SPADV.COLLECT_STATS
to start things all off. Think of it as a manual collection of Advisor Runs for a small period. It also creates the STREAMS$_ADVISOR_COMP_STAT
and STREAMS$_ADVISOR_PATH_STAT
tables.
exec UTL_SPADV.COLLECT_STATS
By default, this runs for 10 minutes creating Advice Runs (think snapshots) every 60 seconds. We would suggest running it with the following, just to get the tables created and so we can move on to setting up the automated version:
exec UTL_SPADV.COLLECT_STATS( interval => 30, num_runs => 2);
You first start of by using:
exec UTL_SPADV.START_MONITORING
The Advice Runs are taken every 60 seconds and retained for 24 hours. We will modify this to be more aggressive and retain data for a longer period in a moment. It continues collecting until we stop it.
To confirm that the Advice Runs are being collected, use:
SET SERVEROUTPUT ON DECLARE this_collecting BOOLEAN; BEGIN this_collecting := UTL_SPADV.IS_MONITORING( job_name => 'STREAMS$_MONITORING_JOB'), IF this_collecting=TRUE THEN DBMS_OUTPUT.PUT_LINE('Good job collecting of advice is automatic.'), ELSE DBMS_OUTPUT.PUT_LINE('Nothing is being collected.'), END IF; END; /
STRM1
to be STREAMed to STRM2
Just simply run the included script on STRM1, loop_50.sql
to create inserts for the next 25 minutes.
declare n_numb number := 1; begin loop Insert into LEARNING.EMPLOYEES (EMPLOYEE_ID, FIRST_NAME, LAST_NAME, TIME) Values (n_numb, 'Hello' || n_numb , 'You', NULL); COMMIT; n_numb := n_numb + 1; DBMS_LOCK.SLEEP(.25); -- quarter second pause exit when n_numb >= 6000; -- about 25 minutes end loop; end; /
-- run this if you used UTL_SPADV.COLLECT_STATS spool run1.txt SET SERVEROUTPUT ON SIZE 50000 BEGIN UTL_SPADV.SHOW_STATS(); END; / spool off;
Once automatic collection of Advisor Runs is set up, use the following:
-- run this if you used UTL_SPADV.START_MONITORING spool run2.txt SET SERVEROUTPUT ON SIZE 50000 BEGIN UTL_SPADV.SHOW_STATS(path_stat_table => 'STREAMS$_PA_SHOW_PATH_STAT'), END; / spool off;
UTL_SPADV
to more aggressive collection scheduleChanging the collections of Advisor Runs is accomplished with the following:
-- more aggressive monitoring every 30 seconds -- retain for 48 hours BEGIN UTL_SPADV.ALTER_MONITORING( interval => 30, retention_time => 48); END; /
UTL_SPADV
to stop collection of data.exec UTL_SPADV.STOP_MONITORING
The collection of data from the previous gathering of Advisor Runs will still be retained.
It is easy to use UTL_SPADV
packages. There are some minor "issues".
GRANT EXECUTE ON sys.dbms_lock TO STRM_ADMIN
. @utlspadv.sql
. It is not installed by default. UTL_SPADV.SHOW_STATS
should be much easier to read.(I honestly think that Oracle support must have some kind of PERL script that makes the output of UTL_SPADV.SHOW_STATS
more readable.)But even with these minor "issues", the use of UTL_SPADV
packages is similar to the use and evolution of DBMS_WORKLOAD_REPOSITORY PACKAGE
. The UTL_SPADV
packages will mature as more people use and ask for enhancements. Until then, the decision to use the UTL_SPADV.SHOW_STATS
or to query the tables created by utlspadv.sql
will be the choice of the Streams Administrator. The twelve core tables created are listed at the end of this chapter.
STREAMS$_PA_COMPONENT
STREAMS$_PA_COMPONENT_LINK
STREAMS$_PA_COMPONENT_PROP
STREAMS$_PA_COMPONENT_STAT
STREAMS$_PA_CONTROL
STREAMS$_PA_DATABASE
STREAMS$_PA_DATABASE_PROP
STREAMS$_PA_MONITORING
STREAMS$_PA_PATH_BOTTLENECK
STREAMS$_PA_PATH_STAT
STREAMS$_PA_SHOW_COMP_STAT
STREAMS$_PA_SHOW_PATH_STAT