ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 编辑outline

编辑outline

原创 Linux操作系统 作者:fufuh2o 时间:2010-03-05 11:56:03 0 删除 编辑

SQL> create table t_o  (a int);

Table created.

SQL> declare
  2  begin
  3  for i in 1..1000 loop
  4  insert into t_o values(i);
  5  end loop;
  6  commit;
  7  end;
  8  /

PL/SQL procedure successfully completed.

 


SQL> create index t_o_i on t_o(a);

Index created.


SQL> execute dbms_stats.gather_table_stats('XH','T_O');

PL/SQL procedure successfully completed.

SQL> explain plan for select * from t_o where a=2;

Explained.

SQL> select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 1971455142

--------------------------------------------------------------------------
| Id  | Operation        | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT |       |     1 |     3 |     1   (0)| 00:00:01 |
|*  1 |  INDEX RANGE SCAN| T_O_I |     1 |     3 |     1   (0)| 00:00:01 |
--------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------

   1 - access("A"=2)

13 rows selected.

SQL> create or replace outline t_o_f on select * from t_o where a=2;

Outline created.

SQL> select hint#,hint_text from ol$hints where ol_name='T_O_F';

no rows selected

SQL> select hint#,hint_text from ol$hints where ol_name='t_o_f';

no rows selected

SQL> drop outline t_o_f;

Outline dropped.

SQL> create or replace private outline t_o_f on select * from t_o where a=2;

Outline created.

SQL> select hint#,hint_text from ol$hints where ol_name='T_O_F';

     HINT#
----------
HINT_TEXT
--------------------------------------------------------------------------------
         1
INDEX(@"SEL$1" "T_O"@"SEL$1" ("T_O"."A"))

         2
OUTLINE_LEAF(@"SEL$1")

         3
ALL_ROWS


     HINT#
----------
HINT_TEXT
--------------------------------------------------------------------------------
         4
OPTIMIZER_FEATURES_ENABLE('10.2.0.4')

         5
IGNORE_OPTIM_××DED_HINTS


SQL> col hint_text fora30
SP2-0158: unknown COLUMN option "fora30"
SQL> col hint_text for a30
SQL> select hint#,hint_text from ol$hints where ol_name='T_O_F';

     HINT# HINT_TEXT
---------- ------------------------------
         1 INDEX(@"SEL$1" "T_O"@"SEL$1" (
           "T_O"."A"))

         2 OUTLINE_LEAF(@"SEL$1")
         3 ALL_ROWS
         4 OPTIMIZER_FEATURES_ENABLE('10.
           2.0.4')

         5 IGNORE_OPTIM_××DED_HINTS

SQL> update ol$hints set hint_text='FULL(@seg$1 T_O)' where hint#=1 and ol_name='T_O_F';

1 row updated.

SQL> commit;

Commit complete.

SQL> execute dbms_outln_edit.refresh_private_outline('T_O_F');

PL/SQL procedure successfully completed.

SQL> alter session set use_private_outlines=true;

Session altered.

SQL> explain plan for select * from t_o where a=2;

Explained.

SQL> select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 1971455142

--------------------------------------------------------------------------
| Id  | Operation        | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT |       |     1 |     3 |     1   (0)| 00:00:01 |
|*  1 |  INDEX RANGE SCAN| T_O_I |     1 |     3 |     1   (0)| 00:00:01 |
--------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------

   1 - access("A"=2)

Note
-----
   - outline "T_O_F" used for this statement

17 rows selected.

SQL> update ol$hints set hint_text='FULL(@sel$1 T_O)' where hint#=1 and ol_name='T_O_F';

1 row updated.

SQL> commit;

Commit complete.

SQL> execute dbms_outln_edit.refresh_private_outline('T_O_F');

PL/SQL procedure successfully completed.

SQL> explain plan for select * from t_o where a=2;

Explained.

SQL> select * from table(dbms_xplan.display);

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 3764148981

--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     1 |     3 |     3   (0)| 00:00:01 |
|*  1 |  TABLE ACCESS FULL| T_O  |     1 |     3 |     3   (0)| 00:00:01 |
--------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------

   1 - filter("A"=2)

Note
-----
   - outline "T_O_F" used for this statement

17 rows selected.


############
Note
-----
   - outline "T_O_F" used for this statement (表示outline是否使用)


另外还可以
execute dbms_outln.clear_used(name=>'&outline_name');清除outline使用标记
select used from dba_outlines where name ='&outline_name';此时应该为unused
执行使用outline的语句
select used from dba_outlines where name ='&outline_name';此时为used

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12020513/viewspace-628678/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-06-26

  • 博文量
    182
  • 访问量
    471648