ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 隐式转换引起的索引失效

隐式转换引起的索引失效

原创 Linux操作系统 作者:q418441117 时间:2013-01-26 10:26:04 0 删除 编辑

                     隐式转换引起的索引失效

SQL> create table test1 (userid varchar2(10));

Table created.

SQL> select * from test1;

no rows selected

SQL> insert into test1  select object_id from dba_objects;

72693 rows created.

SQL> create index id_idx on test1 (userid);

Index created.

SQL> set autotrace trace

SQL> select * from test1 where userid=2;            --条件是number类型


Execution Plan
----------------------------------------------------------
Plan hash value: 4122059633

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

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

   1 - filter(TO_NUMBER("USERID")=2)

Note
-----
   - dynamic sampling used for this statement (level=2)


Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
        116  consistent gets
          0  physical reads
          0  redo size
        523  bytes sent via SQL*Net to client
        523  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

SQL> select * from test1 where userid='2';           --加上引号后变成字符类型


Execution Plan
----------------------------------------------------------
Plan hash value: 1357208269

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

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

   1 - access("USERID"='2')

Note
-----
   - dynamic sampling used for this statement (level=2)


Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
          3  consistent gets
          0  physical reads
          0  redo size
        523  bytes sent via SQL*Net to client
        523  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed

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

上一篇: ORA-17503: ksfdopn:
请登录后发表评论 登录
全部评论

注册时间:2012-09-11

  • 博文量
    203
  • 访问量
    471918