设为首页 加入收藏

TOP

SQL Profile介绍(二)
2014-11-24 07:16:34 来源: 作者: 【 】 浏览:8
Tags:SQL Profile 介绍
L> declare

begin

for i in 1 .. 10000 loop

insert into test values(i);

commit;

end loop;

end;

/

PL/SQL procedure successfully completed.

SQL> create index test_idx on test(n);

Index created.

SQL> exec dbms_stats.gather_table_stats('','TEST');

PL/SQL procedure successfully completed.

set autotrace on

select /*+ no_index(test test_idx) */ * from test where n=1

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

| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

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

| 0 | SELECT STATEMENT | | 1 | 4 | 5 (0)| 00:00:01 |

|* 1 | TABLE ACCESS FULL| TEST | 1 | 4 | 5 (0)| 00:00:01 |

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

SESSION2--SYS

创建并执行tuning task,并运行report tuning task,采用建议的SQL Profile

declare

my_task_name VARCHAR2(30);

my_sqltext CLOB;

begin

my_sqltext := 'select /*+ no_index(test test_idx) */ * from test where n=1';

my_task_name := DBMS_SQLTUNE.CREATE_TUNING_TASK(

sql_text => my_sqltext,

user_name => 'SCOTT',

scope => 'COMPREHENSIVE',

time_limit => 60,

task_name => 'my_sql_tuning_task_2',

description => 'Task to tune a query on a specified table');

end;

/

PL/SQL procedure successfully completed.

begin

DBMS_SQLTUNE.EXECUTE_TUNING_TASK( task_name => 'my_sql_tuning_task_2');

end;

/

PL/SQL procedure successfully completed.

set long 1000

set longchunksize 1000

set linesize 100

SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK( 'my_sql_tuning_task_2') from DUAL;

DBMS_SQLTUNE.REPORT_TUNING_TASK('MY_SQL_TUNING_TASK_2')

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

GENERAL INFORMATION SECTION

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

Tuning Task Name : my_sql_tuning_task_2

Tuning Task Owner : SYS

Workload Type : Single SQL Statement

Scope : COMPREHENSIVE

Time Limit(seconds): 60

Completion Status : COMPLETED

Started at : 10/26/2011 15:07:04

Completed at : 10/26/2011 15:07:08

DBMS_SQLTUNE.REPORT_TUNING_TASK('MY_SQL_TUNING_TASK_2')

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

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

Schema Name: SCOTT

SQL ID : d4wgpc5g0s0vu

SQL Text : select /*+ no_index(test test_idx) */ * from test where n=1

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

FINDINGS SECTION (1 finding)

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

1- SQL Profile Finding (see explain plans section below)

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

DBMS_SQLTUNE.REPORT_TUNING_TASK('MY_SQL_TUNING_TASK_2')

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

A potentially better execution plan was found for this statement.

Recommendation (estimated benefit: 90.95%)

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

首页 上一页 1 2 3 下一页 尾页 2/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Oracle性能调整的要点之SGA 下一篇oracle10g的sysaux空间暴增与空间..

评论

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

·Redis 分布式锁全解 (2025-12-25 17:19:51)
·SpringBoot 整合 Red (2025-12-25 17:19:48)
·MongoDB 索引 - 菜鸟 (2025-12-25 17:19:45)
·What Is Linux (2025-12-25 16:57:17)
·Linux小白必备:超全 (2025-12-25 16:57:14)