你好,游客 登录 注册 搜索
背景:
阅读新闻

数据类型不一致导致的SQL不走索引

[日期:2013-06-04] 来源:Linux社区  作者:snoopy93 [字体:大 中 小]

我们可以看到,在这里Oracle对两个表都执行了全表扫描。

下面再看另外一句:

[lubinsu@localhost ~]$ sqlplus lubinsu/lubinsu

SQL*Plus: Release 10.2.0.1.0 - Production on Sat May 25 12:06:14 2013

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> set timing on
SQL> set autotrace traceonly
SQL> UPDATE t_test_1 a
  2  SET    a.object_type =
  3        (SELECT i.object_type FROM t_test_2 i WHERE i.object_id2 = a.object_id);

49894 rows updated.

Elapsed: 00:00:02.41

Execution Plan
----------------------------------------------------------
Plan hash value: 2786494037

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

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

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

|  0 | UPDATE STATEMENT            |                  | 64296 |  1506K|  137
  (3)| 00:00:02 |

|  1 |  UPDATE                      | T_TEST_1        |      |      |
    |          |

|  2 |  TABLE ACCESS FULL          | T_TEST_1        | 64296 |  1506K|  137
  (3)| 00:00:02 |

|  3 |  TABLE ACCESS BY INDEX ROWID| T_TEST_2        |  603 | 14472 |    6
  (0)| 00:00:01 |

|*  4 |    INDEX RANGE SCAN          | IND_T_TEST_2_ID2 |  241 |      |    1
  (0)| 00:00:01 |

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


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

  4 - access("I"."OBJECT_ID2"=:B1)

Note
-----
  - dynamic sampling used for this statement


Statistics
----------------------------------------------------------
        448  recursive calls
    101974  db block gets
    100838  consistent gets
        110  physical reads
  23668060  redo size
        668  bytes sent via SQL*Net to client
        658  bytes received via SQL*Net from client
          4  SQL*Net roundtrips to/from client
        11  sorts (memory)
          0  sorts (disk)
      49894  rows processed

linux
相关资讯       SQL不走索引 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款