Oracle数据库数据恢复、性能优化

找回密码
注册
搜索
热搜: 活动 交友 discuz
发新帖

29

积分

187

好友

71

主题
1#
发表于 2012-12-6 16:42:59 | 查看: 5566| 回复: 3
RBO优化器模式下2个都可以用的索引用哪一个?

可以通过如下演示说明该问题的哦
  1. SQL> create table testind  as select 1 t1,2 t2 ,3 t3 from dual connect by level <=90000;

  2. Table created.

  3. SQL> create index ind1 on testind(t2,t1);

  4. Index created.

  5. SQL> create index ind2 on testind(t2,t3);

  6. Index created.


  7. SQL> select /*+ RULE */ * from testind where t2=10;

  8. no rows selected


  9. Execution Plan
  10. ----------------------------------------------------------
  11. Plan hash value: 272597711

  12. -----------------------------------------------
  13. | Id  | Operation                   | Name    |
  14. -----------------------------------------------
  15. |   0 | SELECT STATEMENT            |         |
  16. |   1 |  TABLE ACCESS BY INDEX ROWID| TESTIND |
  17. |*  2 |   INDEX RANGE SCAN          | IND2    |
  18. -----------------------------------------------

  19. Predicate Information (identified by operation id):
  20. ---------------------------------------------------

  21.    2 - access("T2"=10)

  22. Note
  23. -----
  24.    - rule based optimizer used (consider using cbo)

  25.    
  26.     alter system flush shared_pool;
  27.     drop index ind1;
  28.    create index ind1 on testind(t2,t1);
  29.    
  30.     select /*+ RULE */ * from testind where t2=10;

  31.         SQL>  select /*+ RULE */ * from testind where t2=10;

  32. no rows selected


  33. Execution Plan
  34. ----------------------------------------------------------
  35. Plan hash value: 3431448338

  36. -----------------------------------------------
  37. | Id  | Operation                   | Name    |
  38. -----------------------------------------------
  39. |   0 | SELECT STATEMENT            |         |
  40. |   1 |  TABLE ACCESS BY INDEX ROWID| TESTIND |
  41. |*  2 |   INDEX RANGE SCAN          | IND1    |
  42. -----------------------------------------------

  43. Predicate Information (identified by operation id):
  44. ---------------------------------------------------

  45.    2 - access("T2"=10)

  46. Note
  47. -----
  48.    - rule based optimizer used (consider using cbo)
复制代码
如以上测试可以说明 同时有2个可用索引时 RBO会选择 更晚 创建 或者 重建的索引, 这是RBO的一点小秘密。
下载专业ORACLE数据库恢复工具PRM-DUL  For Oracle http://www.parnassusdata.com/zh-hans/emergency-services

如果自己搞不定可以找诗檀软件专业ORACLE数据库修复团队成员帮您恢复!

诗檀软件专业数据库修复团队

服务热线 : 13764045638  QQ: 47079569   
2#
发表于 2012-12-7 00:11:46
学习,
刘大 这里 有笔误
SQL> create index ind1 on testind(t2,t3);

Index created.

SQL> create index ind2 on testind(t2,t3);

Index created.

回复 只看该作者 道具 举报

3#
发表于 2012-12-7 14:52:28
你这个字段都完全一样的话,索引是建立不了的。

回复 只看该作者 道具 举报

4#
发表于 2012-12-7 14:55:13
uj12best 发表于 2012-12-7 14:52
你这个字段都完全一样的话,索引是建立不了的。

笔误。。。

回复 只看该作者 道具 举报

您需要登录后才可以回帖 登录 | 注册

QQ|手机版|Archiver|Oracle数据库数据恢复、性能优化

GMT+8, 2024-4-27 02:08 , Processed in 0.052555 second(s), 24 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部
TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569