oracle sqltune,ORACLEdbms_sqltune

论坛 期权论坛 脚本     
已经匿名di用户   2022-5-29 19:30   1073   0

As usually, we do some sql tuning, and we also can do it with the help of oracle dbms_tunne which is the oracle sql tuning advisor.

After oracle 10g, oracle provide one function for sql tuning automatically named dbms_sqltune.

Where can it be used?

We often use it with oracle enterprise manager, grid control, addmrpt or manually do it.

For manually as:

DECLARE

SQLTUNING_TASK VARCHAR2(30);

SQL_TEXT CLOB;

BEGIN

SQL_TEXT := 'select * from t1 where object_id = 2';

SQLTUNING_TASK := DBMS_SQLTUNE.CREATE_TUNING_TASK(

SQL_TEXT => SQL_TEXT,

USER_NAME => 'WINKEY',

SCOPE => 'COMPREHENSIVE',

TIME_LIMIT => 15,

TASK_NAME => 'my_task',

DESCRIPTION => 'winkey'

);

END;

/

SELECT TASK_NAME FROM DBA_ADVISOR_LOG; --sqladvisor log

--execute sql tuing task

BEGIN

DBMS_SQLTUNE.EXECUTE_TUNING_TASK( TASK_NAME => 'my_task');

END;

/

--checking for sql tuing task

SELECT status

FROM USER_ADVISOR_TASKS

WHERE TASK_NAME = 'my_task';

-- Checking the Progress of SQL Tuning Advisor

SELECT SOFAR, TOTALWORK

FROM V$ADVISOR_PROGRESS

WHERE USER_NAME = 'WINKEY' AND TASK_NAME = 'my_task';

SET LONG 2000

SET LONGCHUNKSIZE 1000

SET LINESIZE 100

SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK( 'my_task')

FROM DUAL;

Just do it !

http://www.dengb.com/oracle/702385.htmlwww.dengb.comtruehttp://www.dengb.com/oracle/702385.htmlTechArticleAs usually, we do some sql tuning, and we also can do it with the help of oracle dbms_tunne which is the oracle sql tuning advisor. After oracle 10g, oracle provide one function fo...

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:81
帖子:4969
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP