怎样使用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 的效果怎样,这个有待然后验证下!
怎样使用oracle 的DBMS_SQLTUNE package 来执行 Sql Tuning Advisor 进行sql 自己主动调优的更多相关文章
- Oracle调整顾问(SQL Tuning Advisor 与 SQL Access Advisor
在Oracle数据库出现性能问题时,使用Oracle本身的工具包,给出合理的调优建议是比较省力的做法. tuning advisor 是对输入的sql set的执行计划进行优化accsee advis ...
- 手工执行sql tuning advisor和sql access advisor
sql tuning advisor:创建任务DECLARE my_task_name VARCHAR2(30); my_sqltext CLOB; BEGIN my_sqltext := 'SELE ...
- Oracle SQL Tuning Advisor 测试
如果面对一个需要优化的SQL语句,没有很好的想法,可以先试试Oracle的SQL Tuning Advisor. SQL> select * from v$version; BANNER --- ...
- Oracle 10G强大的SQL优化工具:SQL Tuning Advisor
p { margin-bottom: 0.25cm; direction: ltr; color: rgb(0, 0, 0); line-height: 120%; orphans: 2; widow ...
- [terry笔记]Oracle SQL 优化之sql tuning advisor (STA)
前言:经常可以碰到优化sql的需求,开发人员直接扔过来一个SQL让DBA优化,然后怎么办? 当然,经验丰富的DBA可以从各种方向下手,有时通过建立正确索引即可获得很好的优化效果,但是那些复杂SQL错综 ...
- 使用ORACLE SQL Tuning advisor快速优化低效的SQL语句
ORACLE10G以后版本的SQL Tuning advisor可以从以下四个方面给出优化方案 (1)为统计信息丢失或失效的对象收集统计信息 (2)考虑优化器的任何数据偏差.复杂谓词或失效的统计信 ...
- Oracle自带工具sql优化集-SQL Tuning Advisor (使用心得体会)
如何有效的诊断和监控高负载的SQL对于DBA来说并非是件容易的事情,对SQL语句手工调优需要很多的经验和技巧, 结合个人经验常见如下问题: . 对SQL语句本身进行优化以便获得更优的 ...
- Oracle 11g 禁用 SQL Tuning Advisor 与 auto space advisor
生产上有一套11g数据库alert.log报错ORA-16957: SQL Analyze time limit interrupt. 查询MOS相关文档Troubleshooting: ORA-1 ...
- ORACLE SQL TUNING ADVISOR 使用方法
sql tunning advisor 使用的主要步骤: 1 建立tunning task 2 执行task 3 显示tunning 结果 4 根据建议来运行相应的调优方法 下面来按照这个顺序来实施 ...
随机推荐
- HTTP重定向
404 Not Found301 Moved Permanently302 Found500 Internal Server ErrorHTTP重定向就是通过301和302两种状态码来实现的. 302 ...
- Codeforces 903E Swapping Characters
题目大意 考虑一个未知的长为 $n$($2\le n\le 5000$)由小写英文字母构成的字符串 $s$ .给出 $k$($1\le k\le 2500$,$nk\le 5000$)个字符串 $s_ ...
- 常用的Java基本代码汇总
1.字符串和整型的相互转换 String a= String.valueOf(2); int i = Integer.parseInt(a); 2. 向文件末尾添加内容 BufferedWriter ...
- 归并排序,时间复杂度nlogn
思路: /* 考点: 1. 快慢指针:2. 归并排序. 此题经典,需要消化吸收. 复杂度分析: T(n) 拆分 n/2, 归并 n/2 ...
- Python Base Three
//sixth day to study python(2016/8/7) 32. In python , there are have an special type dictionary , it ...
- java任务调度Timer简单例子
1.创建类TimerTest import java.util.Timer; import java.util.TimerTask; public class TimerTest { private ...
- docker 镜像阿里加速器
1.登录 https://cr.console.aliyun.com/#/imageList 2.点击加速器tab,获取自己的加速器地址,然后执行黑框内的命令. .sudo mkdir -p /etc ...
- bzoj 1038 瞭望塔 半平面交+分段函数
题目大意 给你一座山,山的形状在二维平面上为折线 给出\((x_1,y_1),(x_2,y_2)...(x_n,y_n)\)表示山的边界点或转折点 现在要在\([x_1,x_n]\)(闭区间)中选择一 ...
- Quotes in shell(bash, csh)
There are three kinds of quote: single quote('), double quote("), backslash(\), how shell expla ...
- 【POJ3321】Apple Tree(DFS序,树状数组)
题意:给一棵n个节点的树,每个节点开始有一个苹果,m次操作 1.将某个结点的苹果数异或 1 2.查询一棵子树内的苹果数 n,m<=100000 思路:最近一段时间在思考树上统计问题的算法 发 ...