在运行“自动SQL调整”任务期间或之后的任何时间,您都可以查看调整报告。
调整报告包含有关自动SQL调整任务的所有执行的信息。根据报告中包括的部分,您可以在以下部分中查看信息:
- 一般信息
本节对自动SQL调整任务进行了高级描述,包括有关为报告提供的输入,维护期间调整的SQL语句数以及创建的SQL配置文件数的信息。
- 摘要
本节列出了在维护窗口期间调整的SQL语句(按其SQL标识符)以及每个SQL概要文件的估计收益,或使用SQL概要文件对SQL语句执行测试执行后的执行统计信息。
- 调整结果
本节包含有关由SQL Tuning Advisor分析的每个SQL语句的以下信息:
- 与每个SQL语句相关的所有发现
- 是否在数据库上实现了概要文件,为什么
- 当前是否在数据库上启用了SQL配置文件
- 测试SQL概要文件时捕获的详细执行统计信息
- 解释计划
本节显示由SQL Tuning Advisor分析的每个SQL语句使用的新旧解释计划。
- 失误
本节列出了自动SQL调整任务遇到的所有错误。
本节包含以下主题:
- 使用命令行查看自动SQL优化报告
要生成SQL优化报告CLOB,请执行此DBMS_SQLTUNE.REPORT_AUTO_TUNING_TASK功能。
24.2.4.1使用命令行查看自动SQL调整报告
要将SQL调优报告生成为CLOB,请执行该DBMS_SQLTUNE.REPORT_AUTO_TUNING_TASK函数。
您可以将CLOB变量存储在变量中,然后打印变量以查看报告。
假设条件
本部分假定您要显示最近执行的所有SQL语句,包括未实施的建议。
要创建和访问自动SQL Tuning Advisor报告,请执行以下操作:
- 使用管理员权限将SQL * Plus连接到数据库,然后执行该
DBMS_SQLTUNE.REPORT_AUTO_TUNING_TASK功能。下面的示例生成一个文本报告,以显示在最近执行中分析的所有SQL语句,包括未实施的建议:
VARIABLE my_rept CLOB; BEGIN :my_rept :=DBMS_SQLTUNE.REPORT_AUTO_TUNING_TASK ( begin_exec => NULL , end_exec => NULL , type => 'TEXT' , level => 'TYPICAL' , section => 'ALL' , object_id => NULL , result_limit => NULL ); END; / PRINT :my_rept - 阅读常规信息部分,以了解调优执行的概述。
以下示例显示了在短短7分钟内分析了17条SQL语句的“自动SQL调整”任务:
MY_REPT --------------------------------------------------------------------------- GENERAL INFORMATION SECTION --------------------------------------------------------------------------- Tuning Task Name : SYS_AUTO_SQL_TUNING_TASK Tuning Task Owner : SYS Workload Type : Automatic High-Load SQL Workload Execution Count : 6 Current Execution : EXEC_170 Execution Type : TUNE SQL Scope : COMPREHENSIVE Global Time Limit(seconds) : 3600 Per-SQL Time Limit(seconds) : 1200 Completion Status : COMPLETED Started at : 04/16/2012 10:00:00 Completed at : 04/16/2012 10:07:11 Number of Candidate SQLs : 17 Cumulative Elapsed Time of SQL (s) : 8 - 寻找发现和建议。
如果SQL Tuning Advisor提出了建议,请权衡接受建议的利弊。
下面的示例显示SQL Tuning Advisor找到了一个可能比现有计划更好的语句计划。顾问建议实现SQL配置文件。
--------------------------------------------------------------------------- SQLs with Findings Ordered by Maximum (Profile/Index) Benefit, Object ID --------------------------------------------------------------------------- ob ID SQL ID statistics profile(benefit) index(benefit) restructure ------ ------------- ---------- ---------------- -------------- ----------- 82 dqjcc345dd4ak 58.03% 72 51bbkcd9zwsjw 2 81 03rxjf8gb18jg --------------------------------------------------------------------------- DETAILS SECTION --------------------------------------------------------------------------- Statements with Results Ordered by Max (Profile/Index) Benefit, Object ID --------------------------------------------------------------------------- Object ID : 82 Schema Name: DBA1 SQL ID : dqjcc345dd4ak SQL Text : SELECT status FROM dba_autotask_client WHERE client_name=:1 --------------------------------------------------------------------------- FINDINGS SECTION (1 finding) --------------------------------------------------------------------------- 1- SQL Profile Finding (see explain plans section below) -------------------------------------------------------- A potentially better execution plan was found for this statement. The SQL profile was not automatically created because the verified benefit was too low. Recommendation (estimated benefit: 58.03%) ------------------------------------------ - Consider accepting the recommended SQL profile. execute dbms_sqltune.accept_sql_profile(task_name => 'SYS_AUTO_SQL_TUNING_TASK', object_id => 82, replace => TRUE); Validation results ------------------ The SQL profile was tested by executing both its plan and the original plan and measuring their respective execution statistics. A plan may have been only partially executed if the other could be run to completion in less time. Original Plan With SQL Profile % Improved ------------- ---------------- ---------- Completion Status: COMPLETE COMPLETE Elapsed Time(us): 26963 8829 67.25 % CPU Time(us): 27000 9000 66.66 % User I/O Time(us): 25 14 44 % Buffer Gets: 905 380 58.01 % Physical Read Requests: 0 0 Physical Write Requests: 0 0 Physical Read Bytes: 0 0 Physical Write Bytes: 7372 7372 0 % Rows Processed: 1 1 Fetches: 1 1 Executions: 1 1 Notes ----- 1. The original plan was first executed to warm the buffer cache. 2. Statistics for original plan were averaged over next 9 executions. 3. The SQL profile plan was first executed to warm the buffer cache. 4. Statistics for the SQL profile plan were averaged over next 9 executions.
也可以看看:
《 Oracle数据库PL / SQL软件包和类型参考》提供了完整的参考信息。
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




