设为首页 加入收藏

TOP

sql_tuneadvisor的使用(四)
2015-11-21 01:40:52 来源: 作者: 【 】 浏览:1
Tags:sql_tuneadvisor 使用
------------------------------------------------------------ Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter("EMPNO"=200) 2- Using SQL Profile -------------------- Plan hash value: 2008370210 -------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 39 | 2 (0)| 00:00:01 | | 1 | TABLE ACCESS BY INDEX ROWID| T2 | 1 | 39 | 2 (0)| 00:00:01 | |* 2 | INDEX RANGE SCAN | IDX_T2 | 1 | | 1 (0)| 00:00:01 | -------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("EMPNO"=200) ------------------------------------------------------------------------------- 我们可以看到他提供的建议,执行sql_profile,我们根据他的建议执行这个profile execute dbms_sqltune.accept_sql_profile(task_name => 'test01',task_owner=> 'SCOTT',replace => TRUE); 然后我们再来执行下原来的带hint的语句 select /*+ full(t2) */ * from t2 where empno=200; 13:39:32 scott@orcl> select /*+ full(t2) */ * from t2 where empno=200; Elapsed: 00:00:00.01 Execution Plan ---------------------------------------------------------- Plan hash value: 2008370210 -------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 39 | 2 (0)| 00:00:01 | | 1 | TABLE ACCESS BY INDEX ROWID| T2 | 1 | 39 | 2 (0)| 00:00:01 | |* 2 | INDEX RANGE SCAN | IDX_T2 | 1 | | 1 (0)| 00:00:01 | -------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("EMPNO"=200) Note ----- - SQL profile "SYS_SQLPROF_014a6b5a4a4a0000" used for this statement Statistics ---------------------------------------------------------- 0 recursive calls 0 db block gets 4 consistent gets 0 physical reads 0 redo size 1092 bytes sent via SQL*Net to client 520 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed 可以看到使用了sql_profile 从而走了正确的执行计划 现在我们再来看看其他的情况,我们原来的表上没有索引,看看tune advisor能提供什么样的建议 13:42:44 scott@orcl> select * from t4 where empno=200; Elapsed: 00:00:00.04 Execution Plan ---------------------------------------------------------- Plan hash value: 2560505625 -------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 100 | 15 (0)| 00:00:01 | |* 1 | TABLE ACCESS FULL| T4 | 1 | 100 | 15 (0)| 00:00:01 | -------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter("EMPNO"=200) Note ----- - dynamic sampling used for this statement (level=2)
首页 上一页 1 2 3 4 5 下一页 尾页 4/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇MongoDB创建一个用户自定义角色 下一篇SQL Server中的if...else...结构

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: