怎样使用oracle 的DBMS_SQLTUNE package 来执行 Sql Tuning Advisor 进行sql 自己主动调优



怎样使用oracle 的DBMS_SQLTUNE package 来执行 Sql Tuning Advisor 进行sql 自己主动调优

1》。这里简单举个样例来说明DBMS_SQLTUNE 的使用

首先现运行下某个想要调优的sql,然后获取sqlid

SQL> select * from v$sqltext where sql_text like ‘select * from dual%‘;

ADDRESS          HASH_VALUE SQL_ID        COMMAND_TYPE      PIECE SQL_TEXT

---------------- ---------- ------------- ------------ ---------- ----------------------------------------------------------------

0000000069BC2BE0  942515969 a5ks9fhw2v9s1            3          0 select * from dual

1 row selected.

2》。执行sqltrpt 脚本

sqltrpt 里默认记录两种数据

15 Most expensive SQL in the cursor cache

15 Most expensive SQL in the workload repository

当然这里我们也能够手动输入我们想要调整的其它sql

SQL> @?/rdbms/admin/sqltrpt

15 Most expensive SQL in the cursor cache

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SQL_ID           ELAPSED SQL_TEXT_FRAGMENT

------------- ---------- -------------------------------------------------------

b6usrg82hwsa3      97.69 call dbms_stats.gather_database_stats_job_proc (  )

6gvch1xu9ca3g      38.88 DECLARE job BINARY_INTEGER := :job; next_date DATE := :

cvn54b7yz0s8u      21.34 select /*+ index(idl_ub1$ i_idl_ub11) +*/ piece#,length

dbvkky621gqtr      16.22 SELECT /*+ parallel */ EXTRACTVALUE(VALUE(T), ‘/select_

3ktacv9r56b51       9.68 select owner#,name,namespace,remoteowner,linkname,p_tim

ga9j9xk5cy9s0       7.01 select /*+ index(idl_sb4$ i_idl_sb41) +*/ piece#,length

39m4sx9k63ba2       6.09 select /*+ index(idl_ub2$ i_idl_ub21) +*/ piece#,length

8swypbbr0m372       5.90 select order#,columns,types from access$ where d_obj#=:

db78fxqxwxt7r       5.62 select /*+ rule */ bucket, endpoint, col#, epvalue from

g5m0bnvyy37b1       5.38 select sql_id, plan_hash_value, bucket_id,        begin

424h0nf7bhqzd       5.02  SELECT sqlset_row(sql_id, force_matching_signature,

SQL_ID           ELAPSED SQL_TEXT_FRAGMENT

------------- ---------- -------------------------------------------------------

32hbap2vtmf53       4.31 select position#,sequence#,level#,argument,type#,charse

9s0xa5dgvuq55       4.29 DECLARE job BINARY_INTEGER := :job;  next_date TIMESTAM

d4taszv1bpc0w       4.02 DECLARE   cnt      NUMBER;   bid      NUMBER;   eid

96g93hntrzjtr       3.78 select /*+ rule */ bucket_cnt, row_cnt, cache_cnt, null

15 Most expensive SQL in the workload repository

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SQL_ID           ELAPSED

------------- ----------

SQL_TEXT_FRAGMENT

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

b6usrg82hwsa3     198.03

call dbms_stats.gather_database_stats_job_proc (  )

6gvch1xu9ca3g     169.58

DECLARE job BINARY_INTEGER := :job; next_date DATE := :

1jqcpqf8fpdr8     139.13

select count(*) from dba_objects a, dba_objects b where

SQL_ID           ELAPSED

------------- ----------

SQL_TEXT_FRAGMENT

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

cvn54b7yz0s8u      82.99

select /*+ index(idl_ub1$ i_idl_ub11) +*/ piece#,length

f6cz4n8y72xdc      63.29

SELECT space_usage_kbytes  FROM  v$sysaux_occupants  WH

6mcpb06rctk0x      44.62

call dbms_space.auto_space_advisor_job_proc (  )

SQL_ID           ELAPSED

------------- ----------

SQL_TEXT_FRAGMENT

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

3ktacv9r56b51      42.79

select owner#,name,namespace,remoteowner,linkname,p_tim

12a2xbmwn5v6z      39.87

select owner, segment_name, blocks from dba_segments wh

05s9358mm6vrr      37.59

begin dbms_feature_usage_internal.exec_db_usage_samplin

SQL_ID           ELAPSED

------------- ----------

SQL_TEXT_FRAGMENT

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

5zruc4v6y32f9      33.12

DECLARE job BINARY_INTEGER := :job;  next_date TIMESTAM

dbvkky621gqtr      31.66

SELECT /*+ parallel */ EXTRACTVALUE(VALUE(T), ‘/select_

63n9pwutt8yzw      28.03

MERGE /*+ dynamic_sampling(ST 4) dynamic_sampling_est_c

SQL_ID           ELAPSED

------------- ----------

SQL_TEXT_FRAGMENT

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

7xa8wfych4mad      27.86

SELECT SUM(blocks)  FROM x$kewx_segments  WHERE segment

8swypbbr0m372      26.81

select order#,columns,types from access$ where d_obj#=:

db78fxqxwxt7r      26.37

select /*+ rule */ bucket, endpoint, col#, epvalue from

Specify the Sql id

~~~~~~~~~~~~~~~~~~

Enter value for sqlid: a5ks9fhw2v9s1

Sql Id specified: a5ks9fhw2v9s1

Tune the sql   -----------------------------------------------这里为sql tuning advisor 的 建议

~~~~~~~~~~~~

GENERAL INFORMATION SECTION

-------------------------------------------------------------------------------

Tuning Task Name   : TASK_219

Tuning Task Owner  : SYS

Workload Type      : Single SQL Statement

Scope              : COMPREHENSIVE

Time Limit(seconds): 1800

Completion Status  : COMPLETED

Started at         : 05/17/2014 17:07:54

Completed at       : 05/17/2014 17:07:54

-------------------------------------------------------------------------------

Schema Name: SYS

SQL ID     : a5ks9fhw2v9s1

SQL Text   : select * from dual

-------------------------------------------------------------------------------

There are no recommendations to improve the statement.

-------------------------------------------------------------------------------

备注:在生产环境下没有測试过,不知道Sql Tuning Advisor 的效果怎样,这个有待然后验证下!

时间: 2024-11-07 14:04:59

怎样使用oracle 的DBMS_SQLTUNE package 来执行 Sql Tuning Advisor 进行sql 自己主动调优的相关文章

如何使用oracle 的DBMS_SQLTUNE package 来运行 Sql Tuning Advisor 进行sql 自动调优

 如何使用oracle 的DBMS_SQLTUNE package 来运行 Sql Tuning Advisor 进行sql 自动调优 1>.这里简单举个例子来说明DBMS_SQLTUNE 的使用 首先现执行下某个想要调优的sql,然后获取sqlid SQL> select * from v$sqltext where sql_text like 'select * from dual%'; ADDRESS          HASH_VALUE SQL_ID        COMMAND

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

在Oracle数据库出现性能问题时,使用Oracle本身的工具包,给出合理的调优建议是比较省力的做法. tuning advisor 是对输入的sql set的执行计划进行优化accsee advisor 是对sql set当前如果引入索引.分区的话,性能有多大的提升,给出建议.sql tuning advisor是从一方面给出的建议,access advisor可以针对一个表或者多个表的所有操作给出分析建议,比如说对于select语句他会建议增加索引,而会降低DML的性能,sql access

使用SQL Profile及SQL Tuning Advisor固定执行计划

SQL Profile就是为某一SQL语句提供除了系统统计信息.对象(表和索引等)统计信息之外的其他信息,比如运行环境.额外的更准确的统计信息,以帮助优化器为SQL语句选择更适合的执行计划. SQL Profiles可以说是Outlines的进化.Outlines能够实现的功能SQL Profiles也完全能够实现,而SQL Profiles具有Outlines不具备的优化,最重要的有二点: SQL Profiles更容易生成.更改和控制. SQL Profiles在对SQL语句的支持上做得更好

[terry笔记]Oracle SQL 优化之sql tuning advisor (STA)

前言:经常可以碰到优化sql的需求,开发人员直接扔过来一个SQL让DBA优化,然后怎么办? 当然,经验丰富的DBA可以从各种方向下手,有时通过建立正确索引即可获得很好的优化效果,但是那些复杂SQL错综复杂的表关联,却让DBA们满头大汗. 如下特别介绍一种oracle官方提供的科学优化方法STA,经过实践,不敢说此特性绝对有效,但是可以开阔思路,并且从中学到许多知识,不再用“猜”的方式去创建索引了. SQL优化器SQL Tuning Advisor (STA),是oracle的sql优化补助工具.

ORACLE 11G 禁用 SQL TUNING ADVISOR

生产上有一套11g数据库alert.log报错ORA-16957: SQL Analyze time limit interrupt. 查询MOS相关文档Troubleshooting: ORA-16957: "SQL Analyze time limit interrupt" Errors (文档 ID 1275248.1) The ORA-16957 error is an internal error code used to indicate that SQL Tuning T

Oracle 11g 禁用 SQL Tuning Advisor 与 auto space advisor

生产上有一套11g数据库alert.log报错ORA-16957: SQL Analyze time limit interrupt.  查询MOS相关文档Troubleshooting: ORA-16957: "SQL Analyze time limit interrupt" Errors (文档 ID 1275248.1)    The ORA-16957 error is an internal error code used to indicate that SQL Tuni

ORACLE SQL TUNING ADVISOR 使用方法

sql tunning advisor 使用的主要步骤: 1 建立tunning task 2 执行task 3 显示tunning 结果 4 根据建议来运行相应的调优方法  下面来按照这个顺序来实施一遍:    1  建立测试表以及索引 SQL> CREATE TABLE test_sql_advisor AS SELECT OWNER,OBJECT_NAME,OBJECT_ID FROM DBA_OBJECTS; Table created SQL> select count(*) fro

ORACLE SQL TUNING ADVISOR

sql tunning advisor 使用的主要步骤:1 建立tunning task2 执行task3 显示tunning 结果4 根据建议来运行相应的调优方法 ----ADVISOR授权 1 基于SQL文本建立任务 FUNCTION create_tuning_task(sql_text IN CLOB,bind_list IN sql_binds := NULL,user_name IN VARCHAR2 := NULL,scope IN VARCHAR2 := SCOPE_COMPRE

【oracle】oracledba7 SQL Access Advisor

You find that the execution time of reports in your datawarehouse application is significantly high. You suspect the lack of indexes to be the reason for the degradation in performance. Which advisory comp onent would you refer to, in order to determ