The SQL Access Advisor makes suggestions about indexes and materialized views which might improve system performance. This article describes how to use the SQL Access Advisor in Oracle 10g.

Related articles.

Enterprise Manager

The SQL Access Advisor is accessible from Enterprise Manager. Specific reports can be produced by clicking on the "Advisor Central" link, then the "SQL Access Advisor" link. The resulting page allows you to create a workload and a SQL Access Advisor task. Once the task has completed you can view information about the findings and recommendations.

DBMS_ADVISOR

The DBMS_ADVISOR package can be used to create and execute any advisor tasks, including SQL Access Advisor tasks. The following example shows how it is used to create, execute and display a typical SQL Access Advisor script for the current workload.

DECLARE
l_taskname VARCHAR2(30) := 'test_sql_access_task';
l_task_desc VARCHAR2(128) := 'Test SQL Access Task';
l_wkld_name VARCHAR2(30) := 'test_work_load';
l_saved_rows NUMBER := 0;
l_failed_rows NUMBER := 0;
l_num_found NUMBER;
BEGIN
-- Create a SQL Access Advisor task.
DBMS_ADVISOR.create_task (
advisor_name => DBMS_ADVISOR.sqlaccess_advisor,
task_name => l_taskname,
task_desc => l_task_desc); -- Reset the task.
DBMS_ADVISOR.reset_task(task_name => l_taskname); -- Create a workload.
SELECT COUNT(*)
INTO l_num_found
FROM user_advisor_sqlw_sum
WHERE workload_name = l_wkld_name; IF l_num_found = 0 THEN
DBMS_ADVISOR.create_sqlwkld(workload_name => l_wkld_name);
END IF; -- Link the workload to the task.
SELECT count(*)
INTO l_num_found
FROM user_advisor_sqla_wk_map
WHERE task_name = l_taskname
AND workload_name = l_wkld_name; IF l_num_found = 0 THEN
DBMS_ADVISOR.add_sqlwkld_ref(
task_name => l_taskname,
workload_name => l_wkld_name);
END IF; -- Set workload parameters.
DBMS_ADVISOR.set_sqlwkld_parameter(l_wkld_name, 'ACTION_LIST', DBMS_ADVISOR.ADVISOR_UNUSED);
DBMS_ADVISOR.set_sqlwkld_parameter(l_wkld_name, 'MODULE_LIST', DBMS_ADVISOR.ADVISOR_UNUSED);
DBMS_ADVISOR.set_sqlwkld_parameter(l_wkld_name, 'SQL_LIMIT', DBMS_ADVISOR.ADVISOR_UNLIMITED);
DBMS_ADVISOR.set_sqlwkld_parameter(l_wkld_name, 'ORDER_LIST', 'PRIORITY,OPTIMIZER_COST');
DBMS_ADVISOR.set_sqlwkld_parameter(l_wkld_name, 'USERNAME_LIST', DBMS_ADVISOR.ADVISOR_UNUSED);
DBMS_ADVISOR.set_sqlwkld_parameter(l_wkld_name, 'VALID_TABLE_LIST', DBMS_ADVISOR.ADVISOR_UNUSED); DBMS_ADVISOR.import_sqlwkld_sqlcache(l_wkld_name, 'REPLACE', 2, l_saved_rows, l_failed_rows); -- Set task parameters.
DBMS_ADVISOR.set_task_parameter(l_taskname, '_MARK_IMPLEMENTATION', 'FALSE');
DBMS_ADVISOR.set_task_parameter(l_taskname, 'EXECUTION_TYPE', 'INDEX_ONLY');
DBMS_ADVISOR.set_task_parameter(l_taskname, 'MODE', 'COMPREHENSIVE');
DBMS_ADVISOR.set_task_parameter(l_taskname, 'STORAGE_CHANGE', DBMS_ADVISOR.ADVISOR_UNLIMITED);
DBMS_ADVISOR.set_task_parameter(l_taskname, 'DML_VOLATILITY', 'TRUE');
DBMS_ADVISOR.set_task_parameter(l_taskname, 'ORDER_LIST', 'PRIORITY,OPTIMIZER_COST');
DBMS_ADVISOR.set_task_parameter(l_taskname, 'WORKLOAD_SCOPE', 'PARTIAL');
DBMS_ADVISOR.set_task_parameter(l_taskname, 'DEF_INDEX_TABLESPACE', DBMS_ADVISOR.ADVISOR_UNUSED);
DBMS_ADVISOR.set_task_parameter(l_taskname, 'DEF_INDEX_OWNER', DBMS_ADVISOR.ADVISOR_UNUSED);
DBMS_ADVISOR.set_task_parameter(l_taskname, 'DEF_MVIEW_TABLESPACE', DBMS_ADVISOR.ADVISOR_UNUSED);
DBMS_ADVISOR.set_task_parameter(l_taskname, 'DEF_MVIEW_OWNER', DBMS_ADVISOR.ADVISOR_UNUSED); -- Execute the task.
DBMS_ADVISOR.execute_task(task_name => l_taskname);
END;
/ -- Display the resulting script.
SET LONG 100000
SET PAGESIZE 50000
SELECT DBMS_ADVISOR.get_task_script('test_sql_access_task') AS script
FROM dual;
SET PAGESIZE 24

The value for the SET LONG command should be adjusted to allow the whole script to be displayed.

Quick Tune

If you just want to tune an individual statement you can use the QUICK_TUNE procedure as follows.

BEGIN
DBMS_ADVISOR.quick_tune(
advisor_name => DBMS_ADVISOR.SQLACCESS_ADVISOR,
task_name => 'emp_quick_tune',
attr1 => 'SELECT e.* FROM emp e WHERE UPPER(e.ename) = ''SMITH''');
END;
/

Any recommendations can then be displayed using the previous query with the correct task name specified.

Related Views

The following views can be used to display the SQL Access Advisor output without using Enterprise Manager or the get_task_script function:

  • DBA_ADVISOR_TASKS - Basic information about existing tasks.
  • DBA_ADVISOR_LOG - Status information about existing tasks.
  • DBA_ADVISOR_FINDINGS - Findings identified for an existing task.
  • DBA_ADVISOR_RECOMMENDATIONS - Recommendations for the problems identified by an existing task.

For more information see:

Hope this helps. Regards Tim...

Back to the Top.

SQL Access Advisor in Oracle Database 10g的更多相关文章

  1. Oracle调整顾问(SQL Tuning Advisor 与 SQL Access Advisor

    在Oracle数据库出现性能问题时,使用Oracle本身的工具包,给出合理的调优建议是比较省力的做法. tuning advisor 是对输入的sql set的执行计划进行优化accsee advis ...

  2. SQL Tuning 基础概述09 - SQL Access Advisor

    Oracle官方文档对SQL Access Advisor的描述如下: SQL Access Advisor, which is a tuning tool that provides advice ...

  3. 问题: Oracle Database 10g 未在当前操作系统中经过认证

    问题: Oracle Database 10g 未在当前操作系统中经过认证 在Windows 7中安装Oracle 10g. 使用的Orcale版本是10g. 步骤1: 在Orcale官网上下载,下载 ...

  4. 用DBMS_ADVISOR.SQLACCESS_ADVISOR创建SQL Access Advisor访问优化建议

    使用OEM方式来创建SQL Access Advisor访问优化建议,已经是四五年的事了,下面就来写写怎样使用DBMS_ADVISOR.SQLACCESS_ADVISOR来创建SQL Access A ...

  5. ORACLE DATABASE 10g EXPRESS EDITION LICENSE AGREEMENT

     启动Tomcat之后出现全是英文错误: ORACLE DATABASE 10g EXPRESS EDITION LICENSE AGREEMENT To use this license, yo ...

  6. 手工执行sql tuning advisor和sql access advisor

    sql tuning advisor:创建任务DECLARE my_task_name VARCHAR2(30); my_sqltext CLOB; BEGIN my_sqltext := 'SELE ...

  7. ORACLE DATABASE 10G FALSHBACK 知识整理

    1.知识储备 1)    当出现介质损坏时(如数据文件丢失),任何闪回方法都毫无用处,只能执行标准的备份.还原与恢复. 2.SCN记录方法 SQL>variable x_scn number; ...

  8. SQL Access Advisor

    1.概述: provides advice on improving the performance of a database through partitioning, materialized ...

  9. Oracle Database 10g Express Edition系统文件损坏的解决办法

    1.检查错误代码:ora-10010 亦或是ora-10003,上网找响应的解决办法: 异常状态:登陆不上 常用的方法解决 (1)进入Oracle命令行模式 (2)Shutdown immedaite ...

随机推荐

  1. virtualbox中 Ubuntu挂载共享文件夹

    1. 进入 /mnt 目录 2. 新建目录 share 3. sudo mount -t vboxsf share /mnt/share(其中的第一个share是共享文件夹的名字) 4. 成功

  2. JS实现异步提交

    什么是XMLHttpRequest? XMLHttpRequest对象用于在后台与服务器交换数据 XMLHttpRequst的作用 在不重新加载页面的情况下更新网页 在页面已加载后从服务器请求数据 在 ...

  3. php生成xml数据

    1.php生成xml数据一般有2种方式, 一个是组装字符串,另一个就是使用php内置的系统类 2.使用php内置类生成xml数据 3.拼装字符串生成xml数据 public function stat ...

  4. Python mysql 创建连接

    安装 pymysql 模块 pip3 install pymysql # python2, 默认无 pip 命令 # python3, 默认自带 pip3 命令 mysql基本操作 # 导入 pymy ...

  5. 2016年 CodePen 最热门的前端代码 Top 100

    每年 Codepen 都会公布年度最热门的代码片段,这些片段有的技术超弦,有的超实用.有的超有创意,有空看看都能给我们带来灵感. 同时从 Codepen 的代码上也能学习一些牛人的写法,不管是设[…… ...

  6. bootstrap源码之滚动监听组件scrollspy.js详解

    其实滚动监听使用的情况还是很多的,比如导航居于右侧,当主题内容滚动某一块的时候,右侧导航对应的要高亮. 实现功能 1.当滚动区域内设置的hashkey距离顶点到有效位置时,就关联设置其导航上的指定项 ...

  7. 小tips:JS语法之标签(label)

    JavaScript语言允许,语句的前面有标签(label),相当于定位符,用于跳转到程序的任意位置,标签的格式如下. label: statement 标签可以是任意的标识符,但是不能是保留字,语句 ...

  8. java的优点和误解 《java核心技术卷i》第一章

    <java核心技术卷i>第一章主要内容包括三点: 1:Java白皮书的关键术语:描述Java的十一个关键字: 2:Java applet 3 :关于Java的常见误解   1:第一章:Ja ...

  9. elasticsearch及head插件安装与配置

    1. 环境软件版本说明 系统:ubuntu14.04.1 JDK:1.8 elasticsearch:5.5.2 node:9.11.1 elasticsearch:5.X 2. 环境软件下载说明 1 ...

  10. 关于商米D1S,USB默认权限在关机后丢失的FAQ

    1.机器型号:商米D1S 2.机器系统版本:7.1.2 3.情况描述:双屏的机器不管是银盒子收银还是银盒子智能收银,勾选默认后重启机器还是会提示, 4.解决方案:商米厂商大约会在1月份进行系统更新,到 ...