ACE Director Alum Daniel Morgan, founder of Morgan's Library, is scheduling
complimentary technical Workshops on Database Security for the first 30
Oracle Database customers located anywhere in North America, EMEA, LATAM, or
APAC that send an email to
asra_us@oracle.com. Request a Workshop for
your organization today.
Purpose
DBMS_ADVISOR is part of the server manageability suite of advisors, a set of expert systems that identifies and helps resolve performance problems relating to database server components.
Some advisors have their own packages. For these advisors, Oracle recommends that you use the advisor-specific package rather than DBMS_ADVISOR. Each of the following advisors has its own package, tailored to its specific functionality:
SQL Access Advisor and Segment Advisor are the only advisors with common use cases for DBMS_ADVISOR. Undo Advisor and Compression Advisor do not support DBMS_ADVISOR subprograms.
AUTHID
CURRENT_USER
Constants
Name
Data Type
Value
Advisor Names
ADV_NAME_ADDM
VARCHAR2(30)
'ADDM'
ADV_NAME_COMPRESS
VARCHAR2(30)
'Compression Advisor'
ADV_NAME_DEFAULT
VARCHAR2(30)
'Default Advisor'
ADV_NAME_SEGMENT
VARCHAR2(30)
'Segment Advisor'
ADV_NAME_SPM_EVOLVE
VARCHAR2(30)
'SPM Evolve Advisor'
ADV_NAME_SQLACCESS
VARCHAR2(30)
'SQL Access Advisor'
ADV_NAME_SQLPA
VARCHAR2(30)
'SQL Performance Analyzer'
ADV_NAME_SQLREPAIR
VARCHAR2(30)
'SQL Repair Advisor'
ADV_NAME_SQLTUNE
VARCHAR2(30)
'SQL Tuning Advisor'
ADV_NAME_SQLWM
VARCHAR2(30)
'SQL Workload Manager'
ADV_NAME_STATISTICS
VARCHAR2(30)
'Statistics Advisor'
ADV_NAME_TUNEMV
VARCHAR2(30)
'Tune MView'
ADV_NAME_UNDO
VARCHAR2(30)
'Undo Advisor'
ADV_NAME_ZONEMAP
VARCHAR2(30)
'Zonemap Advisor'
Advisor Numbers
ADV_ID_DEFAULT
NUMBER
0
ADV_ID_ADDM
NUMBER
1
ADV_ID_SQLACCESS
NUMBER
2
ADV_ID_UNDO
NUMBER
3
ADV_ID_SQLTUNE
NUMBER
4
ADV_ID_SEGMENT
NUMBER
5
ADV_ID_SQLWM
NUMBER
6
ADV_ID_TUNEMV
NUMBER
7
ADV_ID_SQLPA
NUMBER
8
ADV_ID_SQLREPAIR
NUMBER
9
ADV_ID_COMPRESS
NUMBER
10
ADV_ID_SPM_EVOLVE
NUMBER
11
ADV_ID_STATISTICS
NUMBER
12
ADV_ID_ZONEMAP
NUMBER
13
Common
ADVISOR_ALL
NUMBER
-995
ADVISOR_CURRENT
NUMBER
-996
ADVISOR_DEFAULT
NUMBER
-997
ADVISOR_UNLIMITED
NUMBER
-998
ADVISOR_UNUSED
NUMBER
-999
SQL Access Advisor
SQLACCESS_ADVISOR
VARCHAR2(30)
ADV_NAME_SQLACCESS
SQLACCESS_GENERAL
VARCHAR2(20)
'SQLACCESS_GENERAL'
SQLACCESS_OLTP
VARCHAR2(20)
'SQLACCESS_OLTP'
SQLACCESS_WAREHOUSE
VARCHAR2(20)
'SQLACCESS_WAREHOUSE'
SQLWORKLOAD_MANAGER
VARCHAR2(30)
ADV_NAME_SQLWM
TUNE_MVIEW_ADVISOR
VARCHAR2(30)
ADV_NAME_TUNEMV
ZONEMAP_MANAGER
VARCHAR2(30)
ADV_NAME_ZONEMAP
Data Types
-- Used to pass a list of task parameters to the execute_task function. Only used for advisor that support multi-execution. TYPE argList IS TABLE OF sys.wri$_adv_parameters.value%TYPE;
-- Identical to DBMS_SQL.VARCHAR2S and is redefined here due to bootstrapping problems TYPE varchar2adv IS TABLE OF VARCHAR2(256) INDEX BY BINARY_INTEGER;
Definitions
dba_advisor_findings
Findings and symptoms and recommendations from the diagnostic monitor
dba_advisor_log
Current task information: status, progress, error messages, execution times
dba_advisor_recommendations
Results from completed diagnostic tasks with recommendations for the problems identified in each run.
The recommendations should be looked at in the order of the RANK column, as this relays the magnitude of the problem for the recommendation. The BENEFIT column gives the benefit to the system you can expect after the recommendation is carried out.
dba_advisor_tasks
Basic information about existing tasks, such as the task Id, task name, and when created
Dependencies
DBA_ADDM_FDG_BREAKDOWN
DBMS_AUTO_ZONEMAP_INTERNAL
USER_ADDM_TASKS
DBA_ADDM_FINDINGS
DBMS_COMPRESSION
USER_ADVISOR_ACTIONS
DBA_ADDM_TASKS
DBMS_IREFSTATS
USER_ADVISOR_EXECUTIONS
DBA_ADVISOR_ACTIONS
DBMS_LOB
USER_ADVISOR_EXEC_PARAMETERS
DBA_ADVISOR_DEF_PARAMETERS
DBMS_MANAGEMENT_PACKS
USER_ADVISOR_FDG_BREAKDOWN
DBA_ADVISOR_EXECUTIONS
DBMS_SMB_INTERNAL
USER_ADVISOR_FINDINGS
DBA_ADVISOR_EXECUTION_TYPES
DBMS_SPACE
USER_ADVISOR_JOURNAL
DBA_ADVISOR_EXEC_PARAMETERS
DBMS_SPM
USER_ADVISOR_LOG
DBA_ADVISOR_FDG_BREAKDOWN
DBMS_SPM_INTERNAL
USER_ADVISOR_PARAMETERS
DBA_ADVISOR_FINDINGS
DBMS_SQLDIAG
USER_ADVISOR_RATIONALE
DBA_ADVISOR_FINDING_NAMES
DBMS_SQLPA
USER_ADVISOR_RECOMMENDATIONS
DBA_ADVISOR_JOURNAL
DBMS_SQLTUNE
USER_ADVISOR_SQLW_JOURNAL
DBA_ADVISOR_LOG
DBMS_SQLTUNE_INTERNAL
USER_ADVISOR_SQLW_PARAMETERS
DBA_ADVISOR_PARAMETERS
DBMS_SQLTUNE_UTIL1
USER_ADVISOR_TASKS
DBA_ADVISOR_PARAMETERS_PROJ
DBMS_SQLTUNE_UTIL2
UTL_FILE
DBA_ADVISOR_RATIONALE
DBMS_STANDARD
WRI$_ADV_ABSTRACT_T
DBA_ADVISOR_RECOMMENDATIONS
DBMS_STATS_ADVISOR
WRI$_ADV_COMPRESSION_T
DBA_ADVISOR_SQLW_JOURNAL
DBMS_SWAT_ARM_INTERNAL
WRI$_ADV_DEF_PARAMETERS
DBA_ADVISOR_SQLW_PARAMETERS
DBMS_SYS_ERROR
WRI$_ADV_HDM_T
DBA_ADVISOR_TASKS
DBMS_UNDO_ADV
WRI$_ADV_OBJSPACE_TREND_T
DBA_AUTO_INDEX_EXECUTIONS
DBMS_WORKLOAD_CAPTURE_I
WRI$_ADV_PARAMETERS
DBA_AUTO_INDEX_STATISTICS
DBMS_WORKLOAD_REPLAY_I
WRI$_ADV_SPM_EVOLVE
DBA_AUTO_INDEX_VERIFICATIONS
DBMS_WRR_INTERNAL
WRI$_ADV_SQLACCESS_ADV
DBA_AUTO_MV_ANALYSIS_ACTIONS
DBMS_XPLAN
WRI$_ADV_SQLPI
DBA_AUTO_MV_ANALYSIS_EXECUTIONS
DBMS_XPLAN_INTERNAL
WRI$_ADV_SQLTUNE
DBA_AUTO_MV_ANALYSIS_
RECOMMENDATIONS
PRVTEMX_SQL
WRI$_ADV_STATS
DBA_AUTO_MV_ANALYSIS_REPORT
PRVT_ACCESS_ADVISOR
WRI$_ADV_TASKS
DBA_AUTO_MV_ANALYSIS_TASK
PRVT_ADVISOR
WRI$_ADV_TUNEMVIEW_ADV
DBA_AUTO_MV_VERIFICATION_REPORT
PRVT_COMPRESSION
WRI$_ADV_UNDO_ADV
DBA_AUTO_MV_VERIFICATION_STATUS
PRVT_HDM
WRI$_ADV_WORKLOAD
DBA_WORKLOAD_DIV_SUMMARY
PRVT_SMGUTIL
WRI$_ADV_ZONEMAP
DBA_WORKLOAD_REPLAY_DIVERGENCE
PRVT_SQLADV_INFRA
WRI$_REPT_ADDM
DBMS_ADDM
PRVT_TUNE_MVIEW
WRI$_REPT_PLAN_DIFF
DBMS_ADVISOR
PRVT_WORKLOAD
WRI$_REPT_SPMEVOLVE
DBMS_ASSERT
PRVT_WORKLOAD_NOPRIV
WRI$_REPT_SQLPI
DBMS_AUTO_INDEX_INTERNAL
USER_ADDM_FDG_BREAKDOWN
WRI$_REPT_SQLT
DBMS_AUTO_SQLTUNE
USER_ADDM_FINDINGS
X$KEHRP
Documented
Yes
Exceptions
Error Code
Reason
ORA-13699
Advisor feature is not currently implemented
First Available
10.1
Generic Advisor Parameters
For the full list of values run the SQL statement below
set linesize 121
col value format a40
desc wri$_adv_def_parameters
SELECT name, datatype, value, description
FROM wri$_adv_def_parameters
ORDER BY 1;
-- ADDM specific parameters; for example
desc dba_advisor_def_parameters
SELECT DISTINCT advisor_name
FROM dba_advisor_def_parameters;
col parameter_value format a30
SELECT parameter_value, is_default
FROM dba_advisor_def_parameters
WHERE advisor_name = 'ADDM';
Generic Advisor Parameter Descriptions
ACTION_LIST
STRINGLIST
Deprecated
COMMENTED_FILTER_LIST
NUMBER
Deprecated
DAYS_TO_EXPIRE
NUMBER
Specifies the expiration time in days for the current SQL Workload object. The value is relative to the last modification date.
Once the data expires, it will become a candidate for removal by an automatic purge operation. Possible values are:
an integer in the range of 0 to 2147483647 (def. 30)
ADVISOR_UNLIMITED
ADVISOR_UNUSED
END_TIME
STRING
Specifies an end time for selecting SQL statements. If the statement did not execute on or before the specified time, it will not be processed.
Each date must be in the standard Oracle form of MM-DD-YYY HH24:MI:SS, where:
DD is the numeric date
MM is the numeric month
YYYY is the numeric year
HH is the hour in 24 hour format
MI is the minute
SS is the second
INVALID_ACTION_LIST
STRINGLIST
Contains a fully qualified list of actions that are not eligible for saving in a workload. An action string is not scanned for correctness.
During workload collection, if a SQL statement's action matches a name in the action list, it will not be processed by the operation. An action name is case sensitive. Possible values are:
single action
comma-delimited action list
ADVISOR_UNUSED
INVALID_MODULE_LIST
STRINGLIST
Contains a fully qualified list of application modules that are not eligible when populating a SQL workload object.
The list elements are comma-delimited, and quoted names are supported. A module string is not scanned for correctness.
During workload collection, if a SQL statement's module matches a name in the list, it will not be processed by the operation. Module names are case sensitive.
Possible values are:
single application
comma-delimited module list
ADVISOR_UNUSED (default)
INVALID_SQL
STRINGLIST
Contains a fully qualified comma-delimited list of text strings that are not eligible when populating a SQL workload object.
A SQL string is not scanned for correctness. During workload collection, if a SQL statement contains a string in the SQL string list, it will not be processed by the operation. Possible values are:
single string
comma-delimited string list
ADVISOR_UNUSED (default)
INVALID_TABLE_LIST
TABLELIST
INVALID_USERNAME_LIST
STRINGLIST
JOURNALING
NUMBER
MODULE_LIST
STRINGLIST
ORDER_LIST
STRING
REPORT_DATE_FORMAT
?
Deprecated
SQL_LIMIT
NUMBER
START_TIME
STRING
USERNAME_LIST
STRINGLIST
VALID_ACTION_LIST
STRINGLIST
VALID_MODULE_LIST
STRINGLIST
VALID_SQLSTRING_LIST
STRINGLIST
VALID_TABLE_LIST
TABLELIST
VALID_USERNAME_LIST
STRINGLIST
Contains a fully qualified list of usernames that are eligible when populating a SQL workload object. The list of elements is comma-delimited: quoted names are supported.
During workload collection, if a SQL statement's username does not match a name in the username list, it will not be processed. A username is not case sensitive unless it is quoted. Possible values are:
single username
comma-delimited username list
ADVISOR_UNUSED (default)
Licensing and Usage
SELECT advisor_name, num_execs
FROM dba_advisor_usage;
dbms_advisor.add_sqlwkld_statement(
workload_name IN VARCHAR2,
module IN VARCHAR2 := '',
action IN VARCHAR2 := '',
cpu_time IN NUMBER := 0,
elapsed_time IN NUMBER := 0,
disk_reads IN NUMBER := 0,
buffer_gets IN NUMBER := 0,
rows_processed IN NUMBER := 0,
optimizer_cost IN NUMBER := 0,
executions IN NUMBER := 1,
priority IN NUMBER := 2,
last_execution_date IN DATE := 'SYSDATE',
stat_period IN NUMBER := 0,
username IN VARCHAR2,
sql_text IN CLOB);
Adds an STS reference to an advisor task. An STS object must have an owner. The owner can be NULL, in which case the owner is assumed to be the SESSION_USER.
dbms_advisor.add_sts_ref(
task_name IN VARCHAR2 NOT NULL,
sts_owner IN VARCHAR2,
workload_name IN VARCHAR2 NOT NULL);
-- the following two calls are equivalent: add_sqlwkld_ref(task_name, workload_name, 1);
add_sts_ref(task_name, NULL, workload_name);
Oracle's comments: "Checks whether the current user has read privileges for another user's tasks. This is typically used only by DBAs to access other users's data, hence we query the dba_* views for now.
General support can be added later on once we define all_* views."
LOL
dbms_advisor.check_read_privs(owner_name IN VARCHAR2);
Note: This procedure is broken in 10g, was reportedly going to be fixed in 11g,
it has been broken in 12cR1 and 12cR2, 18c, 19c, and as you can see is
still worthless in 21.1.
Copies workload object data into a user-specified SQL Tuning Set (STS). No filters are supported.
dbms_advisor.copy_sqlwkld_to_sts(
workload_name IN VARCHAR2,
sts_name IN VARCHAR2,
import_mode IN VARCHAR2 := 'NEW'); -- options are APPEND, NEW, and REPLACE
Creates an external file from a PL/SQL CLOB variable and writes to the file
dbms_advisor.create_file(
buffer IN CLOB,
location IN VARCHAR2, -- Oracle Directory Object Name
filename IN VARCHAR2); -- Name of file to write in directory
dbms_advisor.create_object(
task_name IN VARCHAR2,
object_type IN VARCHAR2,
attr1 IN VARCHAR2 := NULL,
attr2 IN VARCHAR2 := NULL,
attr3 IN VARCHAR2 := NULL,
attr4 IN CLOB := NULL,
object_id OUT NUMBER);
dbms_advisor.create_object(task_name, 'SQL', NULL, NULL, NULL,
'SELECT * FROM sh.sales', obj_id);
dbms_output.put_line(obj_id);
END;
/
SELECT type, task_name
FROM user_advisor_objects;
exec dbms_advisor.execute_task('UW Task');
exec dbms_advisor.delete_task('UW Task');
conn sys@pdbdev as sysdba
revoke advisor from sh;
Overload 2
dbms_advisor.create_object(
task_name IN VARCHAR2,
object_type IN VARCHAR2,
attr1 IN VARCHAR2 := NULL,
attr2 IN VARCHAR2 := NULL,
attr3 IN VARCHAR2 := NULL,
attr4 IN CLOB := NULL,
attr5 IN VARCHAR2 := NULL,
object_id OUT NUMBER);
dbms_advisor.create_sqlwkld(
workload_name IN VARCHAR2,
description IN VARCHAR2 := NULL,
template IN VARCHAR2 := NULL,
is_template IN VARCHAR2 := 'FALSE');
dbms_advisor.create_task(
advisor_name IN VARCHAR2,
task_id OUT NUMBER,
task_name IN OUT VARCHAR2,
task_desc IN VARCHAR2 := NULL,
task_or_template IN VARCHAR2 := NULL,
is_template IN VARCHAR2 := 'FALSE',
how_created IN VARCHAR2 := NULL);
See Demo Below
Overload 2
dbms_advisor.create_task(
advisor_name IN VARCHAR2,
task_name IN VARCHAR2,
task_desc IN VARCHAR2 := NULL,
template IN VARCHAR2 := NULL,
is_template IN VARCHAR2 := 'FALSE',
how_created IN VARCHAR2 := NULL);
TBD
Overload 3
dbms_advisor.create_task(
parent_task_name IN VARCHAR2,
rec_id IN NUMBER,
task_id OUT NUMBER,
task_name IN OUT VARCHAR2,
task_desc IN VARCHAR2,
template IN VARCHAR2);
Evaluates a directive instance and returns the results
dbms_advisor.evaluate_directive(
directive_id IN NUMBER,
instance_name IN VARCHAR2,
task_name IN VARCHAR2 := NULL,
p1 IN CLOB := NULL,
p2 IN CLOB := NULL)
RETURN CLOB;
Returns default task and workload id numbers for the Access Advisor. This routine is typically only called by the GRID Control SQL Access Advisor Wizard
dbms_advisor.get_access_advisor_defaults(
task_name OUT VARCHAR2,
task_id_num OUT NUMBER,
workload_name OUT VARCHAR2,
work_id_num OUT NUMBER);
Retrieves an existing recommendation attribute for the specified task
dbms_advisor.get_rec_attributes(
task_name IN VARCHAR2,
rec_id IN NUMBER,
action_id IN NUMBER,
attribute_name IN VARCHAR2,
value OUT VARCHAR2,
owner_name IN VARCHAR2 := NULL);
Creates and returns a report for the specified task
dbms_advisor.get_task_report (
task_name IN VARCHAR2,
type IN VARCHAR2 := 'TEXT',
level IN VARCHAR2 := 'TYPICAL',
section IN VARCHAR2 := 'ALL',
owner_name IN VARCHAR2 := NULL,
execution_name IN VARCHAR2 := NULL,
object_id IN NUMBER := NULL)
RETURN CLOB;
DECLARE
buf CLOB;
BEGIN
buf := dbms_advisor.get_task_report('UW Task', 'TEXT', 'ALL');
dbms_output.put_line(buf);
END;
/
DECLARE
*
ERROR at line 1:
ORA-13699: Advisor feature is not currently implemented.
ORA-06512: at "SYS.PRVT_ADVISOR", line 2738
ORA-06512: at "SYS.DBMS_ADVISOR", line 585
ORA-06512: at line 4
Creates and returns executable script for the specified task
dbms_advisor.get_task_script(
task_name IN VARCHAR2,
type IN VARCHAR2 := 'IMPLEMENTATION',
rec_id IN NUMBER := NULL,
act_id IN NUMBER := NULL,
owner_name IN VARCHAR2 := NULL,
_name IN VARCHAR2 := NULL,
object_id IN NUMBER := NULL)
RETURN CLOB;
Constructs and loads a SQL workload based on schema evidence
Deprecated in Database 11g
dbms_advisor.import_sqlwkld_schema(
workload_name IN VARCHAR2,
import_mode IN VARCHAR2 := 'NEW', -- APPEND or REPLACE
priority IN NUMBER := 2, -- 1=HIGH, 2=MEDIUM, 3=LOW
saved_rows OUT NUMBER,
failed_rows OUT NUMBER);
Imports data into a workload from the current SQL cache
Deprecated in Database 11g
dbms_advisor.import_sqlwkld_sqlcache(
workload_name IN VARCHAR2,
import_mode IN VARCHAR2 := 'NEW',
priority IN NUMBER := 2,
saved_rows OUT NUMBER,
failed_rows OUT NUMBER);
Imports data into a workload from a SQL Tuning Set
Overload 11g
Overload 1
dbms_advisor.import_sqlwkld_sts (
workload_name IN VARCHAR2,
sts_owner IN VARCHAR2,
sts_name IN VARCHAR2,
import_mode IN VARCHAR2 := 'NEW',
priority IN NUMBER := 2,
saved_rows OUT NUMBER,
failed_rows OUT NUMBER);
conn sys@pdbdev as sysdba
GRANT administer sql tuning set TO sh;
GRANT advisor TO sh;
conn sh/sh@pdbdev
set serveroutput on
-- view a list of available snapshots
set feedback off
set heading on
set linesize 1500
set termout on
set trim on
set trimspool on
set veri off
col instart_fmt noprint;
col inst_name format a12 heading 'Instance';
col db_name format a12 heading 'DB Name';
col snap_id format 99999990 heading 'Snap Id';
col snapdat format a18 heading 'Snap Started' just c;
col lvl format 99 heading 'Snap|Level';
break on inst_name on db_name on host on instart_fmt skip 1;
ttitle off;
SELECT TO_CHAR(s.startup_time,' DD MON "at" HH24:MI:SS') INSTART_FMT,
di.instance_name INST_NAME, di.db_name DB_NAME, s.snap_id SNAP_ID,
TO_CHAR(s.end_interval_time,'DD MON YYYY HH24:MI') SNAPDAT,
s.snap_level LVL
FROM dba_hist_snapshot s, dba_hist_database_instance di
WHERE di.dbid = s.dbid
AND di.instance_number = s.instance_number
AND di.startup_time = s.startup_time
ORDER BY snap_id;
-- create and load a SQLSET
DECLARE
l_cursor dbms_sqltune.sqlset_cursor;
BEGIN
dbms_sqltune.create_sqlset('SH_TSet1', 'Test Tuning Set', 'SH');
dbms_advisor.import_sqlwkld_sts(
workload_name IN VARCHAR2,
sts_name IN VARCHAR2,
import_mode IN VARCHAR2 := 'NEW',
priority IN NUMBER := 2,
saved_rows OUT NUMBER,
failed_rows OUT NUMBER);
Imports data into a workload from a 9i Summary Advisor workload
Deprecated in Database 11g
dbms_advisor.import_sqlwkld_sumadv(
workload_name IN VARCHAR2,
import_mode IN VARCHAR2 := 'NEW',
priority IN NUMBER := 2,
sumadv_id IN NUMBER,
saved_rows OUT NUMBER,
failed_rows OUT NUMBER);
conn sh/sh@pdbdev
DECLARE
wkld_name VARCHAR2(30) := 'UW Wkld';
saved NUMBER;
failed NUMBER;
sumadv_id NUMBER := 394;
BEGIN
dbms_advisor.create_sqlwkld(wkld_name, 'Imported 9i Workload');
Collects a SQL workload from a specified user table
Deprecated in Database 11g
dbms_advisor.import_sqlwkld_user(
workload_name IN VARCHAR2,
import_mode IN VARCHAR2 := 'NEW',
owner_name IN VARCHAR2,
table_name IN VARCHAR2,
saved_rows OUT NUMBER,
failed_rows OUT NUMBER);
conn sh/sh@pdbdev
CREATE TABLE test (
username VARCHAR2(30),
sql_text VARCHAR2(1000));
INSERT INTO test
SELECT 'SH', sql_text
FROM gv$sql
WHERE rownum < 1001;
Stops a currently executing task. The task will end its operations as it would at a normal exit. The user will be able to access any recommendations that exist to this point.
dbms_advisor.interrupt_task(task_name IN VARCHAR2);
SELECT task_name
FROM dba_advisor_tasks
WHERE owner = 'UWCLASS';
Performs an analysis and generates recommendations for a single SQL statement based on 1 to 3 simple attributes
dbms_advisor.quick_tune(
advisor_name IN VARCHAR2,
task_name IN VARCHAR2,
attr1 IN CLOB := NULL,
attr2 IN VARCHAR2 := NULL,
attr3 IN NUMBER := NULL,
template IN VARCHAR2 := NULL,
implement IN BOOLEAN := FALSE,
description IN VARCHAR2 := NULL);
desc user_advisor_templates
set linesize 121
col task_name format a10
col description format a50
SELECT task_name, description
FROM user_advisor_templates;
desc user_advisor_journal
SELECT COUNT(*)
FROM user_advisor_journal;
DECLARE
task_name VARCHAR2(30) := 'UW Task';
BEGIN
dbms_advisor.quick_tune(dbms_advisor.sqlaccess_advisor, task_name,
'SELECT AVG(amount_sold) FROM sh.sales WHERE promo_id=350');
END;
/
SELECT COUNT(*)
FROM user_advisor_journal;
desc user_advisor_journal
col journal_entry format a65
SELECT task_name, journal_entry_type, journal_entry
FROM user_advisor_journal
WHERE task_name = 'UW Task';
desc user_advisor_recommendations
-- Grid Control recommends the actions be accepted
SELECT type, rank, benefit, annotation_status
FROM user_advisor_recommendations
WHERE task_name = 'UW Task';
col command format a30
col attr1 format a25
col attr3 format a25
col attr4 format a25
col attr5 format a25
col attr6 format a25
col error_message format a15
desc user_advisor_actions
-- view the recommended actions
SELECT command, attr1, attr3, attr4
FROM user_advisor_actions
WHERE task_name = 'UW Task';
set long 100000
col attr5 format a100
SELECT attr5
FROM user_advisor_actions;
WHERE task_name = 'UW Task';
desc user_advisor_log
SELECT execution_start, execution_end, status, error_message
FROM user_advisor_log
WHERE task_name = 'UW Task';
desc user_advisor_tasks
col description format a15
col adivsor_name format a15
SELECT description, advisor_name, created, status, recommendation_count,
source, how_created
FROM user_advisor_tasks
WHERE task_name = 'UW Task';
exec dbms_advisor.delete_task('UW Task');
set autotrace on
SELECT AVG(amount_sold) FROM sales WHERE promo_id=350;
SELECT STATEMENT | | 1 | 9 | 177 (20)
SORT AGGREGATE | | 1 | 9 |
PARTITION RANGE ALL | | 229K| 2018K| 177 (20)
TABLE ACCESS FULL | SALES | 229K| 2018K| 177 (20)
----------------------------------------------------
Statistics
----------------------------------------------------
1 recursive calls
0 db block gets
1718 consistent gets
1647 physical reads
0 redo size
438 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
-- implement recommended actions
CREATE MATERIALIZED VIEW LOG ON sales WITH rowid, sequence
(promo_id, amount_sold) INCLUDING NEW VALUES;
CREATE MATERIALIZED VIEW demomv
BUILD IMMEDIATE
REFRESH FAST WITH ROWID
ENABLE QUERY REWRITE AS
SELECT promo_id c1, SUM(amount_sold) m1, COUNT(amount_sold) m2,
COUNT(*) m3
FROM sales
GROUP BY promo_id;
Shows how to decompose a materialized view into two or more materialized views and to restate the materialized view in a way that is more advantageous for fast refresh and query rewrite.
It also shows how to fix materialized view logs and to enable query rewrite.
dbms_advisor.tune_mview(
task_name IN OUT VARCHAR2,
mv_create_stmt IN CLOB);
conn sh/sh@pdbdev
desc user_tune_mview
SELECT *
FROM user_tune_mview;
set serveroutput on
-- failure is a success
DECLARE
task_name VARCHAR2(30) := '';
BEGIN
dbms_advisor.tune_mview(task_name, 'CREATE MATERIALIZED VIEW demomv
REFRESH FAST AS SELECT promo_id c1, AVG(amount_sold) FROM sales WHERE promo_id = 350 GROUP BY promo_id');
dbms_output.put_line(task_name);
END;
/
SELECT *
FROM user_tune_mview;
-- alternatively, save the output to an external file
exec dbms_advisor.create_file (dbms_advisor.get_task_script ('TASK_2380'), 'CTEMP','tune_mview_output.sql');
-- success is a failure
DECLARE
task_name VARCHAR2(30) := '';
BEGIN
dbms_advisor.tune_mview(task_name, 'CREATE MATERIALIZED VIEW demomv
BUILD IMMEDIATE REFRESH FAST WITH ROWID DISABLE QUERY REWRITE AS SELECT promo_id c1, SUM(amount_sold) m1, COUNT(amount_sold) m2, COUNT(*) m3
FROM sales GROUP BY promo_id');
dbms_output.put_line(task_name);
END;
/
Updates an existing task object.
Parameters that are NULL will have no effect on the existing value of the column.
dbms_advisor.update_object(
task_name IN VARCHAR2,
object_id IN NUMBER,
attr1 IN VARCHAR2 := NULL,
attr2 IN VARCHAR2 := NULL,
attr3 IN VARCHAR2 := NULL,
attr4 IN CLOB := NULL,
attr5 IN VARCHAR2 := NULL);
dbms_advisor.update_sqlwkld_attributes(
workload_name IN VARCHAR2,
new_name IN VARCHAR2 := NULL,
description IN VARCHAR2 := NULL,
read_only IN VARCHAR2 := NULL,
is_template IN VARCHAR2 := NULL,
how_created IN VARCHAR2 := NULL);
dbms_advisor.update_sqlwkld_statement(
workload_name IN VARCHAR2,
sql_id IN NUMBER,
application IN VARCHAR2 := NULL,
action IN VARCHAR2 := NULL,
priority IN NUMBER := NULL,
username IN VARCHAR2 := NULL);
TBD
Overload 2
Deprecated in Database 11g
dbms_advisor.update_sqlwkld_statement(
workload_name IN VARCHAR2,
search IN VARCHAR2,
updated OUT NUMBER,
application IN VARCHAR2 := NULL,
action IN VARCHAR2 := NULL,
priority IN NUMBER := NULL,
username IN VARCHAR2 := NULL);
dbms_advisor.update_task_attributes(
task_name IN VARCHAR2,
new_name IN VARCHAR2 := NULL,
description IN VARCHAR2 := NULL,
read_only IN VARCHAR2 := NULL,
is_template IN VARCHAR2 := NULL,
how_created IN VARCHAR2 := NULL);