ITPub博客

首页 > 数据库 > 数据库开发技术 > index 和 index_desc hints的一点有意思的区别

index 和 index_desc hints的一点有意思的区别

原创 数据库开发技术 作者:xiayulai 时间:2008-05-28 09:25:37 0 删除 编辑

2 - access("T1"."OBJECT_ID">=6361 AND "T1"."OBJECT_ID"<=6400)

和

2 - access("T1"."OBJECT_ID">=6361 AND "T1"."OBJECT_ID"<=6400)
filter("T1"."OBJECT_ID"<=6400 AND "T1"."OBJECT_ID">=6361)


SQL>create table t1 as select * from user_objects;

SQL>create index t1_object_id_ind on t1(object_id) tablespace users;


SQL>explain plan for
2 delete /*+ index(t1 t1_object_id_ind)*/from t1 where object_id>=6361 and object_id<=6400;

Explained.

SQL>@?/rdbms/admin/utlxplp

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

--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
--------------------------------------------------------------------------
| 0 | DELETE STATEMENT | | 4 | 52 | 2 |
| 1 | DELETE | T1 | | | |
|* 2 | INDEX RANGE SCAN | T1_OBJECT_ID_IND | 4 | 52 | 2 |
--------------------------------------------------------------------------

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

2 - access("T1"."OBJECT_ID">=6361 AND "T1"."OBJECT_ID"<=6400)
Note: cpu costing is off

15 rows selected.

SQL>explain plan for
2 delete /*+ index_desc(t1 t1_object_id_ind)*/from t1 where object_id>=6361 and object_id<=6400;

Explained.

SQL>@?/rdbms/admin/utlxplp

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

----------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
----------------------------------------------------------------------------------
| 0 | DELETE STATEMENT | | 4 | 52 | 2 |
| 1 | DELETE | T1 | | | |
|* 2 | INDEX RANGE SCAN DESCENDING| T1_OBJECT_ID_IND | 4 | 52 | 2 |
----------------------------------------------------------------------------------

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

2 - access("T1"."OBJECT_ID">=6361 AND "T1"."OBJECT_ID"<=6400)
filter("T1"."OBJECT_ID"<=6400 AND "T1"."OBJECT_ID">=6361)


Note: cpu costing is off

16 rows selected.

SQL>[@more@]

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

下一篇: clob 字段查询
请登录后发表评论 登录
全部评论
  • 博文量
    28
  • 访问量
    30207