- 浏览: 978670 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
孤星119:
好熟悉的数据库字段啊, 上家公司做的项目每天都跟这些字段打招呼 ...
Oracle exp compress参数引起的空间浪费 -
itspace:
quxiaoyong 写道遇到个问题,网上一搜,全他妈这篇文章 ...
数据库连接错误ORA-28547 -
quxiaoyong:
遇到个问题,网上一搜,全他妈这篇文章。你转来转去的有意思吗?
数据库连接错误ORA-28547 -
hctech:
关于version count过高的问题,不知博主是否看过ey ...
某客户数据库性能诊断报告 -
itspace:
invalid 写道写的不错,我根据这个来安装,有点理解错误了 ...
AIX 配置vncserver
闲来无聊,突然在一篇文档中看到Oralce 10g sql tuning adviser,里面列举了该新特性的种种好处:
既然宣传的这么智能,那就体验一下呗。(不过宣传归选出,该特性还是有诸多bug)
使用Sql Tuning Adviser需要以下权限
在zhoul用户下有zhoul表格
创建调优脚本和任务
查询调优状态
郁闷事情发生了,查询调优结果竟然没有值
难道我的测试案例太简单,Oracle认为没有必要提供建议?没道理啊。索性把测试案例弄得复杂点
测试结果依然,奇怪了。突然发现REPORT_TUNING_TASK返回的是clob类型,在本例sqlplus中long 为65536无法显示。
继续在plsqldev中执行,结果显示出来了,当然我们将long设大也能在sqlplus中显示结果,当然我们要根据Oracle的建议做合理评估,不能听之任之。
最后删除sql优化任务
引用
- Determining stale or missing statistics
- Determining better execution plan
- Detecting better access paths and objects required to satisfy them (indexes, materialized views)
- Restructuring SQL
- Determining better execution plan
- Detecting better access paths and objects required to satisfy them (indexes, materialized views)
- Restructuring SQL
既然宣传的这么智能,那就体验一下呗。(不过宣传归选出,该特性还是有诸多bug)
使用Sql Tuning Adviser需要以下权限
引用
SQL> GRANT ADVISOR TO zhoul;
Grant succeeded.
SQL> GRANT SELECT_CATALOG_ROLE TO zhoul;
Grant succeeded.
SQL> GRANT EXECUTE ON DBMS_SQLTUNE TO zhoul;
Grant succeeded.
Grant succeeded.
SQL> GRANT SELECT_CATALOG_ROLE TO zhoul;
Grant succeeded.
SQL> GRANT EXECUTE ON DBMS_SQLTUNE TO zhoul;
Grant succeeded.
在zhoul用户下有zhoul表格
引用
SQL> conn zhoul/zhoul
Connected.
SQL> select obj#,count(*) from zhoul group by obj#;
OBJ# COUNT(*)
---------- ----------
1 141325
2 1
Connected.
SQL> select obj#,count(*) from zhoul group by obj#;
OBJ# COUNT(*)
---------- ----------
1 141325
2 1
创建调优脚本和任务
引用
SQL> DECLARE
2 my_task_name VARCHAR2(30);
3 my_sqltext CLOB;
4 BEGIN
5 my_sqltext := 'SELECT * ' ||
6 'FROM ZHOUL ' || 'WHERE obj#= 1';
7
8 my_task_name := DBMS_SQLTUNE.CREATE_TUNING_TASK(
9 sql_text => my_sqltext,
10 user_name => 'ZHOUL',
11 scope => 'COMPREHENSIVE',
12 time_limit => 60,
13 task_name => 'TEST_sql_tuning_task',
14 description => 'Task to tune a query on a specified PRODUCT');
15 END;
16 /
PL/SQL procedure successfully completed.
SQL> Execute dbms_sqltune.Execute_tuning_task (task_name => 'TEST_sql_tuning_task');
PL/SQL procedure successfully completed.
2 my_task_name VARCHAR2(30);
3 my_sqltext CLOB;
4 BEGIN
5 my_sqltext := 'SELECT * ' ||
6 'FROM ZHOUL ' || 'WHERE obj#= 1';
7
8 my_task_name := DBMS_SQLTUNE.CREATE_TUNING_TASK(
9 sql_text => my_sqltext,
10 user_name => 'ZHOUL',
11 scope => 'COMPREHENSIVE',
12 time_limit => 60,
13 task_name => 'TEST_sql_tuning_task',
14 description => 'Task to tune a query on a specified PRODUCT');
15 END;
16 /
PL/SQL procedure successfully completed.
SQL> Execute dbms_sqltune.Execute_tuning_task (task_name => 'TEST_sql_tuning_task');
PL/SQL procedure successfully completed.
查询调优状态
引用
SQL> select status from dba_advisor_log where task_name='TEST_sql_tuning_task';
STATUS
-----------
COMPLETED
STATUS
-----------
COMPLETED
郁闷事情发生了,查询调优结果竟然没有值
引用
SQL> select count(*) from DBA_SQLTUNE_PLANS;
COUNT(*)
----------
2
SQL> set serveroutput on
SQL> set long 65536
SQL> set longchunksize 65536
SQL> set linesize 100
SQL> select dbms_sqltune.report_tuning_task('TEST_sql_tuning_task') from dual;
SQL>
COUNT(*)
----------
2
SQL> set serveroutput on
SQL> set long 65536
SQL> set longchunksize 65536
SQL> set linesize 100
SQL> select dbms_sqltune.report_tuning_task('TEST_sql_tuning_task') from dual;
SQL>
难道我的测试案例太简单,Oracle认为没有必要提供建议?没道理啊。索性把测试案例弄得复杂点
引用
SQL> DECLARE
2 my_task_name VARCHAR2(30);
3 my_sqltext CLOB;
4 BEGIN
5 my_sqltext := 'SELECT a.* FROM ZHOUL a,TTT b where a.obj#=b.obj# and a.obj#=1';
6
7 my_task_name := DBMS_SQLTUNE.CREATE_TUNING_TASK(
8 sql_text => my_sqltext,
9 user_name => 'ZHOUL',
10 scope => 'COMPREHENSIVE',
11 time_limit => 60,
12 task_name => 'TEST_sql_tuning_task2',
13 description => 'Task to tune a query on a specified PRODUCT');
14 END;
15 /
2 my_task_name VARCHAR2(30);
3 my_sqltext CLOB;
4 BEGIN
5 my_sqltext := 'SELECT a.* FROM ZHOUL a,TTT b where a.obj#=b.obj# and a.obj#=1';
6
7 my_task_name := DBMS_SQLTUNE.CREATE_TUNING_TASK(
8 sql_text => my_sqltext,
9 user_name => 'ZHOUL',
10 scope => 'COMPREHENSIVE',
11 time_limit => 60,
12 task_name => 'TEST_sql_tuning_task2',
13 description => 'Task to tune a query on a specified PRODUCT');
14 END;
15 /
测试结果依然,奇怪了。突然发现REPORT_TUNING_TASK返回的是clob类型,在本例sqlplus中long 为65536无法显示。
引用
FUNCTION REPORT_TUNING_TASK RETURNS CLOB
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
TASK_NAME VARCHAR2 IN
TYPE VARCHAR2 IN DEFAULT
LEVEL VARCHAR2 IN DEFAULT
SECTION VARCHAR2 IN DEFAULT
OBJECT_ID NUMBER IN DEFAULT
RESULT_LIMIT NUMBER IN DEFAULT
OWNER_NAME VARCHAR2 IN DEFAULT
Argument Name Type In/Out Default?
------------------------------ ----------------------- ------ --------
TASK_NAME VARCHAR2 IN
TYPE VARCHAR2 IN DEFAULT
LEVEL VARCHAR2 IN DEFAULT
SECTION VARCHAR2 IN DEFAULT
OBJECT_ID NUMBER IN DEFAULT
RESULT_LIMIT NUMBER IN DEFAULT
OWNER_NAME VARCHAR2 IN DEFAULT
继续在plsqldev中执行,结果显示出来了,当然我们将long设大也能在sqlplus中显示结果,当然我们要根据Oracle的建议做合理评估,不能听之任之。
引用
GENERAL INFORMATION SECTION
-------------------------------------------------------------------------------
Tuning Task Name : TEST_sql_tuning_task2
Tuning Task Owner : ZHOUL
Scope : COMPREHENSIVE
Time Limit(seconds) : 60
Completion Status : COMPLETED
Started at : 11/26/2010 14:15:45
Completed at : 11/26/2010 14:15:48
Number of Statistic Findings : 1
Number of Index Findings : 1
-------------------------------------------------------------------------------
Schema Name: ZHOUL
SQL ID : 0t9f1af0u9gqz
SQL Text : SELECT a.* FROM ZHOUL a,TTT b where a.obj#=b.obj# and a.obj#=1
-------------------------------------------------------------------------------
FINDINGS SECTION (2 findings)
-------------------------------------------------------------------------------
1- Statistics Finding
---------------------
Table "ZHOUL"."ZHOUL" was not analyzed.
Recommendation
--------------
- Consider collecting optimizer statistics for this table.
execute dbms_stats.gather_table_stats(ownname => 'ZHOUL', tabname =>
'ZHOUL', estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE,
method_opt => 'FOR ALL COLUMNS SIZE AUTO');
Rationale
---------
The optimizer requires up-to-date statistics for the table in order to
select a good execution plan.
2- Index Finding (see explain plans section below)
--------------------------------------------------
The execution plan of this statement can be improved by creating one or more
indices.
Recommendation (estimated benefit: 100%)
----------------------------------------
- Consider running the Access Advisor to improve the physical schema design
or creating the recommended index.
create index ZHOUL.IDX$$_812E0001 on ZHOUL.TTT('OBJ#');
Rationale
---------
Creating the recommended indices significantly improves the execution plan
of this statement. However, it might be preferable to run "Access Advisor"
using a representative SQL workload as opposed to a single statement. This
will allow to get comprehensive index recommendations which takes into
account index maintenance overhead and additional space consumption.
-------------------------------------------------------------------------------
EXPLAIN PLANS SECTION
-------------------------------------------------------------------------------
1- Original
-----------
Plan hash value: 3430618738
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 222K| 276M| 133 (4)| 00:00:03 |
|* 1 | HASH JOIN | | 222K| 276M| 133 (4)| 00:00:03 |
|* 2 | INDEX RANGE SCAN | TTT_IDX | 2 | 10 | 2 (0)| 00:00:01 |
|* 3 | TABLE ACCESS FULL| ZHOUL | 111K| 137M| 130 (3)| 00:00:03 |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("A"."OBJ#"="B"."OBJ#")
2 - access("B"."OBJ#"=1)
3 - filter("A"."OBJ#"=1)
2- Using New Indices
--------------------
Plan hash value: 1793892349
-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 222K| 276M| 132 (4)| 00:00:03 |
|* 1 | HASH JOIN | | 222K| 276M| 132 (4)| 00:00:03 |
|* 2 | INDEX RANGE SCAN | IDX$$_812E0001 | 2 | 10 | 1 (0)| 00:00:01 |
|* 3 | TABLE ACCESS FULL| ZHOUL | 111K| 137M| 130 (3)| 00:00:03 |
-------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("A"."OBJ#"="B"."OBJ#")
2 - access("B"."OBJ#"=1)
3 - filter("A"."OBJ#"=1)
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Tuning Task Name : TEST_sql_tuning_task2
Tuning Task Owner : ZHOUL
Scope : COMPREHENSIVE
Time Limit(seconds) : 60
Completion Status : COMPLETED
Started at : 11/26/2010 14:15:45
Completed at : 11/26/2010 14:15:48
Number of Statistic Findings : 1
Number of Index Findings : 1
-------------------------------------------------------------------------------
Schema Name: ZHOUL
SQL ID : 0t9f1af0u9gqz
SQL Text : SELECT a.* FROM ZHOUL a,TTT b where a.obj#=b.obj# and a.obj#=1
-------------------------------------------------------------------------------
FINDINGS SECTION (2 findings)
-------------------------------------------------------------------------------
1- Statistics Finding
---------------------
Table "ZHOUL"."ZHOUL" was not analyzed.
Recommendation
--------------
- Consider collecting optimizer statistics for this table.
execute dbms_stats.gather_table_stats(ownname => 'ZHOUL', tabname =>
'ZHOUL', estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE,
method_opt => 'FOR ALL COLUMNS SIZE AUTO');
Rationale
---------
The optimizer requires up-to-date statistics for the table in order to
select a good execution plan.
2- Index Finding (see explain plans section below)
--------------------------------------------------
The execution plan of this statement can be improved by creating one or more
indices.
Recommendation (estimated benefit: 100%)
----------------------------------------
- Consider running the Access Advisor to improve the physical schema design
or creating the recommended index.
create index ZHOUL.IDX$$_812E0001 on ZHOUL.TTT('OBJ#');
Rationale
---------
Creating the recommended indices significantly improves the execution plan
of this statement. However, it might be preferable to run "Access Advisor"
using a representative SQL workload as opposed to a single statement. This
will allow to get comprehensive index recommendations which takes into
account index maintenance overhead and additional space consumption.
-------------------------------------------------------------------------------
EXPLAIN PLANS SECTION
-------------------------------------------------------------------------------
1- Original
-----------
Plan hash value: 3430618738
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 222K| 276M| 133 (4)| 00:00:03 |
|* 1 | HASH JOIN | | 222K| 276M| 133 (4)| 00:00:03 |
|* 2 | INDEX RANGE SCAN | TTT_IDX | 2 | 10 | 2 (0)| 00:00:01 |
|* 3 | TABLE ACCESS FULL| ZHOUL | 111K| 137M| 130 (3)| 00:00:03 |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("A"."OBJ#"="B"."OBJ#")
2 - access("B"."OBJ#"=1)
3 - filter("A"."OBJ#"=1)
2- Using New Indices
--------------------
Plan hash value: 1793892349
-------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 222K| 276M| 132 (4)| 00:00:03 |
|* 1 | HASH JOIN | | 222K| 276M| 132 (4)| 00:00:03 |
|* 2 | INDEX RANGE SCAN | IDX$$_812E0001 | 2 | 10 | 1 (0)| 00:00:01 |
|* 3 | TABLE ACCESS FULL| ZHOUL | 111K| 137M| 130 (3)| 00:00:03 |
-------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("A"."OBJ#"="B"."OBJ#")
2 - access("B"."OBJ#"=1)
3 - filter("A"."OBJ#"=1)
-------------------------------------------------------------------------------
最后删除sql优化任务
引用
SQL> exec dbms_sqltune.drop_tuning_task('TEST_sql_tuning_task2');
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
发表评论
-
buffer cache 的内部结构
2020-03-18 14:21 576BUFFER CACHE作为数据块的 ... -
Oracle OMC介绍
2020-03-18 13:19 484Oracle管理云服务(OMC)的大数据平台,自动收集的企业 ... -
参加Oracle勒索病毒防范专题培训会议
2019-09-27 17:15 5112019年7月22日,受邀参加Oracle勒索病毒防范专题培训 ... -
记一次内存换IO的Oracle优化
2019-09-27 16:50 826某客户数据库从P595物理 ... -
如何定位Oracle SQL执行计划变化的原因
2019-07-03 14:49 1458性能优化最难的是能够 ... -
如何定位Oracle SQL执行计划变化的原因
2018-10-30 09:24 1185性能优化最难的是能够 ... -
数据库性能优化目标
2018-10-08 10:59 518从数据库性能优化的场 ... -
数据库无法打开的原因及解决办法
2018-10-05 20:45 2117数据库的启动是一个相当复杂的过程。比如,Oracle在启动之前 ... -
怎么样彻底删除数据库?
2018-09-18 11:10 598Oracle提供了drop database命令用来删除数据库 ... -
Oracle减少日志量的方法
2018-09-10 10:17 865LGWR进程将LOG BUFFER中的 ... -
如何快速关闭数据库
2018-09-09 13:14 1231“一朝被蛇咬,十年怕井绳”。在没被“蛇”咬之前,很多DBA喜欢 ... -
关于《如何落地智能化运维》PPT
2018-05-17 10:19 1128在DTCC 2018发表《如何落地智能化运维》演讲,主要内容如 ... -
记录在redhat5.8平台安装oracle11.2容易忽视的几个问题
2018-05-11 19:58 577问题一:ping不通问题 在虚拟机上安装好linux系统后, ... -
《Oracle DBA实战攻略》第一章
2018-05-11 10:42 945即日起,不定期更新《OracleDBA实战攻略》一书电子版,请 ... -
Oracle 12c新特性
2018-05-11 10:33 898查询所有pdb [oracle@gj4 ~]$ sqlplu ... -
关于修改memory_target的值后数据库无法启动的问题
2017-02-28 12:24 3981操作系统:RHEL6.5 数据库版本:11.2.0.4 ... -
10g rac安装error while loading shared libraries libpthread.so.0 问题
2017-02-28 12:22 69311g rac安装在二节点跑脚本一般会报此错误: 解决这个问 ... -
记一次Oracle会话共享模式故障处理过程
2017-02-27 19:16 798故障简述 XXX第八人民医院HIS数据库7月13日11点左右从 ... -
RESMGR:cpu quantum等待事件处理过程
2017-02-27 18:23 2615由于数据库上线过程中出现大量的RESMGR:cpu quant ... -
谈谈log file sync
2014-03-19 14:18 1757数据库中的log file sync等待事件指的是,当user ...
相关推荐
SQL Tuning Advisor(STA)是Oracle数据库中的一个强大工具,用于优化SQL语句的性能。通过自动化的诊断过程,STA能够帮助数据库管理员(DBA)识别出低效的SQL语句,并提供改进建议。本文将详细介绍如何利用SQL ...
oracle 10gADDM 和 SQL Tuning Advisor
使用ORACLE SQL Tuning advisor快速优化低效的SQL语句, 这里是一个使用范例,有9个步骤, 后面 其他语句,都按照这个步骤来做就可以了。
### Oracle Database 10g SQL Tuning Workshop #### 概述 Oracle Database 10g SQL Tuning Workshop 是一个专门针对 Oracle 数据库管理员 (DBA) 和开发人员的专业培训课程。该课程旨在帮助用户理解并掌握如何有效地...
SQL调整工具集(SQL Tuning Set,STS)是Oracle 10g的SQL Tuning Advisor特性的一个组成部分。每个调整工具集都包含一个或几个SQL语句,以及正确解释它们所需的上下文信息。SQL Tuning Advisor用一个调整工具集作为...
根据提供的文件信息,我们可以推断出这是一份关于Oracle Database 10g SQL Tuning的培训资料。下面将从以下几个方面来深入解析这份文档中所包含的重要知识点。 ### 一、Oracle Database 10g SQL Tuning 的概念 ...
12. **SQL优化顾问**:Oracle提供内置的SQL优化工具,如SQL Tuning Advisor和Automatic Workload Repository (AWR),它们能分析SQL性能并提供改进建议。 13. **物化视图**:对于固定的复杂查询,创建物化视图可以...
- **版本更新**:Oracle Database 11g 是 Oracle 公司推出的一个重要的数据库管理系统版本,它在 Oracle 10g 的基础上进行了多项改进和增强。 - **新特性**:包括分区改进、内存管理优化、安全性提升以及自动诊断...
通过Advisor工具,如SQL Tuning Advisor,系统会分析SQL语句并提供改进建议,如创建索引、重写查询或调整绑定变量。 3. **SQL Performance Analyzer**:这是一个强大的工具,用于在实际负载下测试SQL语句的性能变化...
在IT领域,尤其是在数据库管理与优化方面,Oracle Database 10g SQL Tuning Workshop是一个关键的知识点,它涉及了如何有效提升Oracle 10g数据库性能的重要技术与实践。以下是对这一主题的深入解析,旨在为数据库...
综上所述,Oracle 10g Performance Tuning涉及到大量的监控视图和性能指标,通过这些工具,DBA可以对数据库进行深度分析,找出性能瓶颈,并采取相应措施进行优化,从而提高系统的响应速度和整体性能。
SQL Access Advisor是Oracle 10g提供的一种工具,用于建议如何改进SQL语句的性能。它可以识别出性能不佳的SQL语句,并推荐创建新的索引或调整现有索引策略。此外,它还可以生成SQL Profile以帮助优化特定的SQL语句。...
《Oracle 11g 数据库Tuning.Training.Materials》是一个深入探讨Oracle 11g数据库性能优化的培训资料集合,主要包括两份重要的文档:Appendix_A.pdf和D52163GC10_ep.pdf。这两份文档是Oracle 11g SQL调优的关键学习...
这涉及识别和重写低效的SQL语句,利用执行计划(EXPLAIN PLAN)进行分析,并使用SQL Tuning Advisor等工具来优化查询。 4. 索引优化:索引是提高数据库查询性能的关键因素。要对索引进行维护,包括创建和删除索引,...
12. **SQL Tuning Advisor**: - 这个内置顾问提供全面的SQL调优建议,包括索引创建、统计信息收集和执行计划修改。 13. **Materialized Views**: - 材料化视图在11g中得到增强,支持实时刷新和快速查询,尤其...
除了基本的优化技巧外,《ORACLE 11g SQL 权威指南》还介绍了多种高级优化工具,如SQL Profiler、SQL Tuning Advisor和AWR(Automatic Workload Repository)。这些工具可以帮助识别性能瓶颈,提供调优建议,并监控...
Oracle 10g之后的优化器支持两种模式,一个是normal模式,一个是tuning模式。在大多数情况下,优化器处于normal模式。基于CBO的normal模式只考虑很小部分的执行计划集合用于选择哪个执行计划,因为它需要在尽可能短...
此外,10g还增加了SQL Tuning Advisor,帮助分析和调整性能低下的SQL语句,提升查询效率。 在数据库安全方面,Oracle 10g增强了权限和角色管理,以及审计功能。Fine-Grained Access Control (FGAC)允许更细致的权限...